當前位置: 首頁>>代碼示例>>C#>>正文


C# Assembly類代碼示例

本文整理匯總了C#中Assembly的典型用法代碼示例。如果您正苦於以下問題:C# Assembly類的具體用法?C# Assembly怎麽用?C# Assembly使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Assembly類屬於命名空間,在下文中一共展示了Assembly類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: WithIncludesTests

    public WithIncludesTests()
    {
        beforeAssemblyPath = Path.GetFullPath(Path.Combine(TestContext.CurrentContext.TestDirectory,@"..\..\..\AssemblyToProcess\bin\Debug\AssemblyToProcess.dll"));
#if (!DEBUG)
        beforeAssemblyPath = beforeAssemblyPath.Replace("Debug", "Release");
#endif

        afterAssemblyPath = beforeAssemblyPath.Replace(".dll", "3.dll");
        File.Copy(beforeAssemblyPath, afterAssemblyPath, true);

        var assemblyResolver = new MockAssemblyResolver
            {
                Directory = Path.GetDirectoryName(beforeAssemblyPath)
            };
        var moduleDefinition = ModuleDefinition.ReadModule(afterAssemblyPath,new ReaderParameters
            {
                AssemblyResolver = assemblyResolver
            });
        var weavingTask = new ModuleWeaver
                              {
                                  ModuleDefinition = moduleDefinition,
                                  AssemblyResolver = assemblyResolver,
                                  IncludeNamespaces = new List<string>{"MyNameSpace"},
                                  LogWarning =s => warnings.Add(s)
                              };

        weavingTask.Execute();
        moduleDefinition.Write(afterAssemblyPath);

        assembly = Assembly.LoadFile(afterAssemblyPath);
    }
開發者ID:Fody,項目名稱:EmptyConstructor,代碼行數:31,代碼來源:WithIncludesTests.cs

示例2: AddAssembly

 public void AddAssembly(Assembly assembly)
 {
     if (assembly == null)
     {
         throw new ArgumentNullException("assembly");
     }
     if (!this.rawAssemblyLoaders.Contains(assembly))
     {
         try
         {
             this.rawAssemblyLoaders[assembly] = new AssemblyLoader(this, assembly, this.localAssembly == assembly);
             if (this.TypesChanged != null)
             {
                 FireEventsNoThrow(this.TypesChanged, new object[] { this, EventArgs.Empty });
             }
         }
         catch (Exception exception)
         {
             this.typeLoadErrors[assembly.FullName] = exception;
             if (this.TypeLoadErrorsChanged != null)
             {
                 FireEventsNoThrow(this.TypeLoadErrorsChanged, new object[] { this, EventArgs.Empty });
             }
         }
     }
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:26,代碼來源:TypeProvider.cs

示例3: IntegrationTests

    public IntegrationTests()
    {
        beforeAssemblyPath = Path.GetFullPath(@"..\..\..\AssemblyToProcess\bin\Debug\AssemblyToProcess.dll");
        #if (!DEBUG)

        beforeAssemblyPath = beforeAssemblyPath.Replace("Debug", "Release");
        #endif

        afterAssemblyPath = beforeAssemblyPath.Replace(".dll", "2.dll");
        File.Copy(beforeAssemblyPath, afterAssemblyPath, true);

        var assemblyResolver = new MockAssemblyResolver
            {
                Directory = Path.GetDirectoryName(beforeAssemblyPath)
            };
        var moduleDefinition = ModuleDefinition.ReadModule(afterAssemblyPath,new ReaderParameters
            {
                AssemblyResolver = assemblyResolver
            });
        var weavingTask = new ModuleWeaver
                              {
                                  ModuleDefinition = moduleDefinition,
                                  AssemblyResolver = assemblyResolver,
                              };

        weavingTask.Execute();
        moduleDefinition.Write(afterAssemblyPath);

        assembly = Assembly.LoadFile(afterAssemblyPath);
    }
開發者ID:GeertvanHorrik,項目名稱:Equals,代碼行數:30,代碼來源:IntegrationTests.cs

示例4: ResourceModule

		internal ResourceModule(Assembly assembly, string scopeName, string location)
			: base(assembly.universe)
		{
			this.assembly = assembly;
			this.scopeName = scopeName;
			this.location = location;
		}
開發者ID:hindlemail,項目名稱:mono,代碼行數:7,代碼來源:ResourceModule.cs

示例5: AssemblyDetailsForm_Load

        private void AssemblyDetailsForm_Load(object sender, EventArgs e)
        {
            manager = new DBManager(RevitDocument);

            //if (this.IsAdd)
            //{
            //    lblTitle.Text = "";
            //}
            //else
            //{
                toSwap = CurrentAssembly;
            //    lblToSwap.Text = toSwap.AssemblyName;
                loadInformation(toSwap);
            //}
            List<Assembly> fromModel = manager.RetrieveWallInfo();
            //List<Assembly> options = null;
            //if (this.IsAdd)
            //options = manager.getAllAssemblies();
            //options.AddRange(fromModel);

            //else
            //    options = manager.getAssembliesByCode(toSwap.AssemblyCode);
            //if (options != null)
            //{
            //    foreach (Assembly a in options)
            //        cboAlternatives.Items.Add(a);
            //}
        }
開發者ID:jrivera777,項目名稱:RevitLibrary,代碼行數:28,代碼來源:AssemblyDetailsForm.cs

示例6: ClassValidator

 public ClassValidator(string xamlFileName, Assembly localAssembly, string rootNamespace)
 {
     this.xamlFileName = xamlFileName;
     this.localAssembly = localAssembly;
     this.eventArgs = null;
     this.rootNamespace = rootNamespace;
 }
開發者ID:nlh774,項目名稱:DotNetReferenceSource,代碼行數:7,代碼來源:ClassValidator.cs

示例7: Instantiate

 public static void Instantiate(Assembly a, Interpreter interp)
 {
     Hashtable table = interp.VarTable;
     try {
         CodeChunk chunk = (CodeChunk)a.CreateInstance("CsiChunk");
         chunk.Go(table);
         // vs 0.8 we display the type and value of expressions.  The variable $_ is
         // always set, which is useful if you want to save the result of the last
         // calculation.
         if (interp.returnsValue && DumpingValue) {
             object val = table["_"];
             Type type = val.GetType();
             string stype = type.ToString();
             if (stype.StartsWith("System."))  // to simplify things a little bit...
                 stype = stype.Substring(7);
             stype = "("+stype+")";
             if (val is string) {
                 Print(stype,"'"+val+"'");
             } else
             if (val is IEnumerable) {
                 Print(stype);
                 Dumpl((IEnumerable)val);
             } else
                 Print(stype,val);
         }
     }  catch(Exception ex) {
         Print(ex.GetType() + " was thrown: " + ex.Message);
     }
 }
開發者ID:stevedonovan,項目名稱:cs-repl,代碼行數:29,代碼來源:interpreter.cs

示例8: AssemblyWeaver

    static AssemblyWeaver()
    {
        BeforeAssemblyPath = Path.GetFullPath(@"..\..\..\AssemblyToProcess\bin\Debug\AssemblyToProcess.dll");
        BeforeAssemblyPathSymbols = Path.ChangeExtension(BeforeAssemblyPath, "pdb");

        #if (!DEBUG)
        BeforeAssemblyPath = BeforeAssemblyPath.Replace("Debug", "Release");
        BeforeAssemblyPathSymbols = BeforeAssemblyPathSymbols.Replace("Debug", "Release");
        #endif
        AfterAssemblyPath = BeforeAssemblyPath.Replace(".dll", "2.dll");
        AfterAssemblyPathSymbols = Path.ChangeExtension(AfterAssemblyPath, "pdb");

        File.Copy(BeforeAssemblyPath, AfterAssemblyPath, true);
        File.Copy(BeforeAssemblyPathSymbols, AfterAssemblyPathSymbols, true);

        var assemblyResolver = new MockAssemblyResolver();
        var moduleDefinition = ModuleDefinition.ReadModule(AfterAssemblyPath, new ReaderParameters { ReadSymbols = true });

        var weavingTask = new ModuleWeaver
        {
            ModuleDefinition = moduleDefinition,
            AssemblyResolver = assemblyResolver,
            LogError = LogError,
            LogInfo = LogInfo,
            DefineConstants = new[] { "DEBUG" }, // Always testing the debug weaver
        };

        weavingTask.Execute();
        moduleDefinition.Write(AfterAssemblyPath, new WriterParameters { WriteSymbols = true });

        Assembly = Assembly.LoadFile(AfterAssemblyPath);
    }
開發者ID:RobertGiesecke,項目名稱:Visualize,代碼行數:32,代碼來源:AssemblyWeaver.cs

示例9: MainWindow

 public MainWindow(ref Assembly asm)
     : base(Gtk.WindowType.Toplevel)
 {
     this.asm = asm;
     Build ();
     parser = new Parser();
 }
開發者ID:aelinden,項目名稱:OruStuff,代碼行數:7,代碼來源:MainWindow.cs

示例10: GetBuildDateTime

#pragma warning restore 0649


        static DateTime GetBuildDateTime(Assembly assembly)
        {
            if (File.Exists(assembly.Location))
            {
                var buffer = new byte[Math.Max(Marshal.SizeOf(typeof(_IMAGE_FILE_HEADER)), 4)];
                using (var fileStream = new FileStream(assembly.Location, FileMode.Open, FileAccess.Read))
                {
                    fileStream.Position = 0x3C;
                    fileStream.Read(buffer, 0, 4);
                    fileStream.Position = BitConverter.ToUInt32(buffer, 0); // COFF header offset
                    fileStream.Read(buffer, 0, 4); // "PE\0\0"
                    fileStream.Read(buffer, 0, buffer.Length);
                }
                var pinnedBuffer = GCHandle.Alloc(buffer, GCHandleType.Pinned);
                try
                {
                    var coffHeader = (_IMAGE_FILE_HEADER)Marshal.PtrToStructure(pinnedBuffer.AddrOfPinnedObject(), typeof(_IMAGE_FILE_HEADER));

                    return TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1) 
                        + new TimeSpan(coffHeader.TimeDateStamp * TimeSpan.TicksPerSecond));
                }
                finally
                {
                    pinnedBuffer.Free();
                }
            }
            return new DateTime();
        }
開發者ID:lscyane,項目名稱:KCBr,代碼行數:31,代碼來源:FormAbout.cs

示例11: AssemblyWeaver

    public AssemblyWeaver(string assemblyPath, List<string> referenceAssemblyPaths = null)
    {
        if (referenceAssemblyPaths == null)
        {
            referenceAssemblyPaths  = new List<string>();
        }
        assemblyPath = FixAssemblyPath(assemblyPath);

        var newAssembly = assemblyPath.Replace(".dll", "2.dll");
        File.Copy(assemblyPath, newAssembly, true);

        var assemblyResolver = new MockAssemblyResolver();
        foreach (var referenceAssemblyPath in referenceAssemblyPaths)
        {
            var directoryName = Path.GetDirectoryName(referenceAssemblyPath);
            assemblyResolver.AddSearchDirectory(directoryName);
        }
        var readerParameters = new ReaderParameters
        {
            AssemblyResolver = assemblyResolver
        };
        var moduleDefinition = ModuleDefinition.ReadModule(newAssembly, readerParameters);
        var weavingTask = new ModuleWeaver
        {
            ModuleDefinition = moduleDefinition,
            AssemblyResolver = assemblyResolver,
            LogError = LogError,
            ReferenceCopyLocalPaths = referenceAssemblyPaths
        };

        weavingTask.Execute();
        moduleDefinition.Write(newAssembly);

        Assembly = Assembly.LoadFrom(newAssembly);
    }
開發者ID:GavinOsborn,項目名稱:MethodTimer,代碼行數:35,代碼來源:AssemblyWeaver.cs

示例12: run

 public void run(Assembly item)
 {
     item
         .all_types()
         .where(x => !exclusion_policy.is_satisfied_by(x))
         .each(x => add_registration_for(x));
 }
開發者ID:mokhan,項目名稱:mo.money,代碼行數:7,代碼來源:auto_wire_components_in_to_the.cs

示例13: Generate

        protected override Assembly Generate()
        {
            var nt = Host.NameTable;
            var mscorlib = Host.LoadAssembly(Host.CoreAssemblySymbolicIdentity);
            var assembly = new Assembly
                               {
                                   Name = nt.GetNameFor(AssemblyName),
                                   ModuleName = nt.GetNameFor(DllName),
                                   Kind = ModuleKind.DynamicallyLinkedLibrary,
                                   TargetRuntimeVersion = mscorlib.TargetRuntimeVersion,
                                   MetadataFormatMajorVersion = 2
                               };
            assembly.AssemblyReferences.Add(mscorlib);

            var rootNamespace = new RootUnitNamespace();
            assembly.UnitNamespaceRoot = rootNamespace;
            rootNamespace.Unit = assembly;

            // define module
            DefineModule(assembly, rootNamespace);

            var typeA = GenerateTypeA(rootNamespace);
            assembly.AllTypes.Add(typeA);

            var baseType = GenericTypeInstance.GetGenericTypeInstance(typeA, new[] { Host.PlatformType.SystemString }, Host.InternFactory);
            var typeB = GenerateTypeB(rootNamespace, baseType);
            assembly.AllTypes.Add(typeB);

            return assembly;
        }
開發者ID:vestild,項目名稱:nemerle,代碼行數:30,代碼來源:CCI.GenericBaseClassAndOverrideOfNonPublicVirtualMethod.cs

示例14: TinyMCECodeGenerator

 public TinyMCECodeGenerator()
 {
     Context = new AssemblyContext();
     Assembly = new Assembly
     {
         Usings = new List<string> 
             { 
                 "System",
                 "System.Collections.Generic",
             }
     };
     Context.Assemblies.Add(Assembly);
     var asm = new Assembly
     {
         Classes = new List<Class>
         {
             new Class{Name="void"},
             new Class{Name="object"},
             new Class{Name="bool"},
             new Class{Name="string"},
             new Class{Name="Array"},
             new Class{Name="int"},
             new Class{Name="Function", IsDelegate=true},
         }
     };
     Context.Assemblies.Add(asm);
     ObjectClass = Context.GetClass("object");
 }
開發者ID:hultqvist,項目名稱:SharpKit-SDK,代碼行數:28,代碼來源:TinyMCECodeGenerator.cs

示例15: GetTypeTrue

	static int GetTypeTrue (Assembly a)
	{
		string typename = "InheritanceDemand";
		Type t = a.GetType (typename, true);
		Console.WriteLine ("*0* Can get type '{0}' with security.", t);
		return 0;
	}
開發者ID:nobled,項目名稱:mono,代碼行數:7,代碼來源:reftype4.cs


注:本文中的Assembly類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。