C#의 메타데이터
메타데이터의 C#은 프로그램을 설명하는 바이너리 정보로 정의되며 이 정보는 공용 언어 런타임 이식 가능한 실행 파일이나 메모리에 저장됩니다. 이식 가능한 실행 파일에서 코드를 컴파일하면 메타데이터가 파일의 또 다른 영역 부분에 삽입되고 이 모든 코드는 이제 MSIL 형식(Microsoft Intermediate Language)으로 변환된 다음 코드가 파일의 다른 파티션 부분으로 이동됩니다. 어셈블리에서 정의되고 참조되는 모든 데이터 형식과 데이터 멤버는 메타데이터 내에 저장됩니다. 런타임에 C# 코드를 실행하는 동안 메모리에서 메타데이터가 로드됩니다. C# 메타데이터의 주요 목적은 클래스, 데이터 멤버, 상속 및 클래스의 데이터 유형 등에 대한 정보를 아는 것입니다. 파일의 메타데이터는 테이블과 힙 데이터 구조로 구성됩니다.
메타데이터 활용
메타데이터의 용도는 다음과 같습니다.
- 이름, 가시성, 기본 클래스, 인터페이스 등과 같은 어셈블리 데이터 유형에 대한 설명을 제공합니다.
- 메서드, 필드, 속성, 이벤트 및 중첩 유형과 같은 데이터 멤버를 제공합니다.
- 타입과 멤버를 수정하는 요소에 대한 추가 설명도 제공합니다.
- 이름, 버전, 공개 키 등과 같은 ID가 있습니다.
- 간단한 프로그래밍 모델의 핵심이며 IDL(인터페이스 정의 언어) 파일, 헤더 파일이 필요하지 않게 됩니다.
메타데이터 유형
다음은 메타데이터 유형의 그림입니다.
메타데이터의 역할
메타데이터의 역할은 다음과 같습니다.
C#에서 메타데이터는 어떻게 작동하나요?
C# 메타데이터는 데이터에 대한 정보를 알고 작업했습니다.
구문:
using packageName;//used for insert the packages in C# public class MyApp { public static int Main() { //data types Console.WriteLine("Required Message"); } //user defined methods for other logics }
C#의 메타데이터 예
다음은 C#의 메타데이터 예입니다.
예시 #1
3개의 숫자 곱셈
코드: Multiplication.cs
using System; //Used for declaring the package or used for importing existed packege public class Multiplication//declaring the class { public static int Main ()// main method for displaying the output { //declaring and defining the varaiables int x = 50; int y = 20; int z=30; //Printing the output of the multiplication of 2 numbers Console.WriteLine ("Multiplication of {0},{1} and {2} is {3}",x,y,z,multiplication(x,y,z)); return 0; } public static int multiplication(int x, int y, int z)// multiplication() method implemention { return (x * y*z);// return multiplication of 3 numbers } }
출력:
설명:
- 약식에서 볼 수 있듯이 실제 데이터를 볼 수 있습니다. 메타데이터나 바이너리 데이터를 원할 경우 기계 생성 코드 내부의 컴파일러를 볼 수 있습니다. 이는 항상 암호화되어 인간이 이해할 수 없습니다.
예시 #2
광장 면적
코드: SquareOfArea.cs
using System; //Used for declaring the package or used for importing existed packege public class SquareArea//declaring the class { public static int Main ()// main method for displaying the output { //declaring and defining the varaiables int x = 50; //Printing the output of the areaOfSquare Console.WriteLine ("Area of Square is {0}",areaOfSquare(x)); return 0; } public static int areaOfSquare(int x)// multiplication() method implemention { return (x*x);// return area Of Square } }
출력:
설명:
- 약식에서 볼 수 있듯이 실제 데이터를 볼 수 있습니다. 메타데이터나 바이너리 데이터를 원할 경우 기계 생성 코드 내부의 컴파일러를 볼 수 있습니다. 이는 항상 암호화되어 인간이 이해할 수 없습니다.
예시 #3
데이터를 사용한 다중 클래스
코드: MultiData.net
using System; //Used for declaring the package or used for importing existed packege using System.Collections.Generic; //Used for declaring the package or used for importing existed packege public class Entity {//declaring the class //setters and getters for set and get the data public string Name {get;set;} public string Uses {get;set;} //toString method to overide predefined String data public override string ToString() { string output1=string.Format("My Name is {0}", Name); string output2=string.Format(" He is: {0}", Uses); return output1+output2; } } //declaring interface with reference class extention public interface IMeta<T> where T: class { //setters and getter for set and get the data T Inner {get;set;} stringMetaData {get;set;} } //declaring interface with reference class extention public interface IStorage<T> where T: class { //method definition for save the data T Save(); } //declaring the class by extending Imeta and IStorage interfaces public class Meta<T> : IMeta<T>, IStorage<T> where T: class { //creating a generic dictionary variable private static Dictionary<T, Meta<T>> _stash = new Dictionary<T, Meta<T>>(); //constructor for the class public Meta(T item) { Inner = item; } //setters and getters for set and get the data public T Inner {get;set;} public string MetaData {get;set;} //method implementation for operator public static implicit operator T(Meta<T> meta) { if (! _stash.ContainsKey(meta.Inner)) _stash.Add(meta.Inner, meta); returnmeta.Inner; } public static implicit operator Meta<T>(T item) { try { return _stash[item]; } catch { return null; } } //save the data to repository public T Save() { return this; } } //declaring the class public static class MetaHelper { //method definition for return the data public static IMeta<T>GetMeta<T>(T item) where T: class { return (Meta<T>)item; } //method definition for store the data public static IStorage<T>GetStorage<T>(T item) where T: class { return (Meta<T>)item; } } //declaring the class public class Program { //Entity type for createEntity method definition with 2 arguments public static Entity CreateEntity(string name, string uses) { //creating a variable var result = new Meta<Entity>(new Entity(){ Name = name, Uses = uses }); //adding data to the variable that is metadata result.MetaData = "Paramesh"; return result; } //test method to test the data public static void Main() { //Passing the values to createEntity method varent = CreateEntity("Amardeep", "Good Person"); //types casting ent into Meta class Meta<Entity> meta = (Meta<Entity>)ent; //creating variables varimeta = MetaHelper.GetMeta<Entity>(ent); varistore = MetaHelper.GetStorage<Entity>(ent); var stored = istore.Save(); //Displaying output Console.WriteLine("MetaData: {0} {1} {2} {3}", imeta.MetaData, imeta.Inner.Name, stored.Name, stored.Uses); Console.WriteLine(ent); if (meta != null) Console.WriteLine(meta.MetaData); elseConsole.WriteLine("This is not a meta type"); } }
출력:
설명:
- 약식에서 볼 수 있듯이 실제 데이터를 볼 수 있습니다. 메타데이터나 바이너리 데이터를 원할 경우 기계 생성 코드 내부의 컴파일러를 볼 수 있습니다. 이는 항상 암호화되어 인간이 이해할 수 없습니다.
결론
C#의 메타데이터는 데이터에 대한 데이터를 알기 위해 사용됩니다. 이는 모두 바이너리 형식으로 암호화되어 있어 사람이 이해할 수 없으므로 바이너리 코드를 일반 코드로 변환하여 로직을 분석합니다.
위 내용은 C#의 메타데이터의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

Video Face Swap
완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

인기 기사

뜨거운 도구

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

뜨거운 주제











C#을 사용한 Active Directory 가이드. 여기에서는 소개와 구문 및 예제와 함께 C#에서 Active Directory가 작동하는 방식에 대해 설명합니다.

C#의 난수 생성기 가이드입니다. 여기서는 난수 생성기의 작동 방식, 의사 난수 및 보안 숫자의 개념에 대해 설명합니다.

C# 데이터 그리드 뷰 가이드. 여기서는 SQL 데이터베이스 또는 Excel 파일에서 데이터 그리드 보기를 로드하고 내보내는 방법에 대한 예를 설명합니다.

멀티 스레딩과 비동기식의 차이점은 멀티 스레딩이 동시에 여러 스레드를 실행하는 반면, 현재 스레드를 차단하지 않고 비동기식으로 작업을 수행한다는 것입니다. 멀티 스레딩은 컴퓨팅 집약적 인 작업에 사용되며 비동기식은 사용자 상호 작용에 사용됩니다. 멀티 스레딩의 장점은 컴퓨팅 성능을 향상시키는 것이지만 비동기의 장점은 UI 스레드를 차단하지 않는 것입니다. 멀티 스레딩 또는 비동기식을 선택하는 것은 작업의 특성에 따라 다릅니다. 계산 집약적 작업은 멀티 스레딩을 사용하고 외부 리소스와 상호 작용하고 UI 응답 성을 비동기식으로 유지 해야하는 작업을 사용합니다.
