public override void AssembleNew(Cosmos.Assembler.Assembler aAssembler, object aMethodInfo) { var allTemplates = Assembly.GetExecutingAssembly().GetTypes(); con.WriteLine("---------------------------------"); foreach (var template in allTemplates) { if (!template.IsClass || typeof(sys.MulticastDelegate).IsAssignableFrom(template.BaseType) || template.IsInterface || template.Name.ToLower().Contains("<") || template.Name.ToLower().Contains("boot") || template.Name.ToLower().Contains("gc") || template.Name.ToLower().Contains("plug") || template.Name.ToLower().Contains("asm")) { continue; } con.WriteLine(template.Name); foreach (var variable in template.GetFields((BindingFlags)int.MaxValue))// BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.FlattenHierarchy)) { if (variable.FieldType.IsClass) { con.WriteLine(" Clas " + variable.Name); } else { con.WriteLine(" Elem " + variable.Name); } } } con.WriteLine("---------------------------------"); }
/// <summary> /// 製品名文字列を取得 /// </summary> /// <returns>製品名文字列</returns> public static string GetProductString() { return ((Attribute.GetCustomAttribute (SRA.GetExecutingAssembly() , typeof(AssemblyProductAttribute) ) as AssemblyProductAttribute ).Product); }
/// <summary> /// 権利表示文字列を取得 /// </summary> /// <returns>権利表示文字列</returns> public static string GetCopyrightString() { return ((Attribute.GetCustomAttribute (SRA.GetExecutingAssembly() , typeof(AssemblyCopyrightAttribute) ) as AssemblyCopyrightAttribute ).Copyright); }
/// <summary> /// 説明文字列を取得 /// </summary> /// <returns>説明文字列</returns> public static string GetDescriptionString() { return ((Attribute.GetCustomAttribute (SRA.GetExecutingAssembly() , typeof(AssemblyDescriptionAttribute) ) as AssemblyDescriptionAttribute ).Description); }
/// <summary> /// タイトル文字列を取得 /// </summary> /// <returns>タイトル文字列</returns> public static string GetTitleString() { return ((Attribute.GetCustomAttribute (SRA.GetExecutingAssembly() , typeof(AssemblyTitleAttribute) ) as AssemblyTitleAttribute ).Title); }
/// <summary> /// Gets the real assembly name of the class provided. /// </summary> /// <typeparam name="T">The type to get the assembly name from.</typeparam> /// <returns>The name of the assembly title, if available. Otherwise, the executing assembly name.</returns> public static string GetAssemblyName <T>() { // get real assembly name, if possible. object[] attribs = typeof(T).Assembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), false); if (attribs.Length > 0) { var titleAttribute = (AssemblyTitleAttribute)attribs[0]; if (titleAttribute.Title.Length > 0) { return(titleAttribute.Title); } } // couldn't get the title attribute, use executing assembly name. return(SRAssembly.GetExecutingAssembly().GetName().Name); }
public static void CreateTileSet() { Type tileType = typeof(Tile); Assembly assembly = Assembly.GetExecutingAssembly(); var tileClasses = assembly.GetTypes().Where(t => t.IsSubclassOf(tileType)); foreach (Type tile in tileClasses) { Tile tileObject = Activator.CreateInstance(tile) as Tile; tile.InvokeMember( "SetDefaults", BindingFlags.InvokeMethod, null, tileObject, null ); } }
public static XmlDocument LoadFileSumData() { using ( var stream = Assembly.GetExecutingAssembly() .GetManifestResourceStream("DNN.Modules.SecurityAnalyzer.Resources.sums.resources")) { if (stream != null) { var xmlDocument = new XmlDocument(); xmlDocument.Load(stream); return(xmlDocument); } else { return(null); } } }
CreateCodeGroup(SecurityElement el) { if (el == null || !el.Tag.Equals("CodeGroup")) { throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Argument_WrongElementType"), "<CodeGroup>")); } Contract.EndContractBlock(); String className; int classNameLength; int classNameStart; if (!ParseElementForObjectCreation(el, BuiltInCodeGroup, out className, out classNameStart, out classNameLength)) { goto USEREFLECTION; } switch (classNameLength) { case 12: // NetCodeGroup if (String.Compare(className, classNameStart, "NetCodeGroup", 0, classNameLength, StringComparison.Ordinal) == 0) { return(new NetCodeGroup()); } else { goto USEREFLECTION; } case 13: // FileCodeGroup if (String.Compare(className, classNameStart, "FileCodeGroup", 0, classNameLength, StringComparison.Ordinal) == 0) { return(new FileCodeGroup()); } else { goto USEREFLECTION; } case 14: // UnionCodeGroup if (String.Compare(className, classNameStart, "UnionCodeGroup", 0, classNameLength, StringComparison.Ordinal) == 0) { return(new UnionCodeGroup()); } else { goto USEREFLECTION; } case 19: // FirstMatchCodeGroup if (String.Compare(className, classNameStart, "FirstMatchCodeGroup", 0, classNameLength, StringComparison.Ordinal) == 0) { return(new FirstMatchCodeGroup()); } else { goto USEREFLECTION; } default: goto USEREFLECTION; } USEREFLECTION: Type groupClass = null; CodeGroup group = null; new ReflectionPermission(ReflectionPermissionFlag.MemberAccess).Assert(); groupClass = GetClassFromElement(el, true); if (groupClass == null) { return(null); } if (!(typeof(CodeGroup).IsAssignableFrom(groupClass))) { throw new ArgumentException(Environment.GetResourceString("Argument_NotACodeGroupType")); } group = (CodeGroup)Activator.CreateInstance(groupClass, true); Contract.Assert(groupClass.Module.Assembly != Assembly.GetExecutingAssembly(), "This path should not get called for mscorlib based classes"); return(group); }
static void Main(string[] args) { var assembly = Assembly.GetExecutingAssembly(); int totalCount = 0; var dictionary = new Dictionary <string, string>(); foreach (FileInfo fileInfo in new DirectoryInfo(new FileInfo(assembly.Location).DirectoryName).EnumerateFiles("*.log*").OrderBy(x => x.LastWriteTimeUtc)) { Console.WriteLine("File: " + fileInfo.Name); using (StreamReader stream = fileInfo.OpenText()) { while (!stream.EndOfStream) { var line = stream.ReadLine(); //Console.WriteLine("line: " + line); //const string search = @"Begin Parallel processing BRs count: (\d+)"; //const string search = "Requesting BR processing for chunk count: "; //const string search = @"Adding (\d+) messages to collector ActionBlock processing"; //const string search = @"BEGIN Try getting permissions of BR"; //const string search = @"BRs waiting in line: (\d+), vanilla ACL queue:"; const string beginSearch = @"BEGIN Try getting permissions of BR .*, \(ID: (\d+)\)"; const string endSearch = @"END Try getting permissions of BR .*, \(ID: (\d+)\)"; var match = Regex.Match(line, beginSearch); if (match.Success) { var resourceId = match.Groups[1].Value; dictionary[resourceId] = match.Value; } match = Regex.Match(line, endSearch); if (match.Success) { var resourceId = match.Groups[1].Value; if (dictionary.ContainsKey(resourceId)) { dictionary.Remove(resourceId); } else { Console.WriteLine("ERROR: found end without a previous begin for: " + resourceId + ", " + match.Value); } } //var match = Regex.Match(line, beginSearch); //if (match.Success) { // if (match.Groups.Count > 1) { // string resultString = match.Groups[1].Value; // Console.WriteLine("resultString: " + match.Groups[1].Value); // var count = Int32.Parse(resultString); // Console.WriteLine("count: " + count); // totalCount += count; // } // else { // ++totalCount; // } //} } } } foreach (string key in dictionary.Keys) { Console.WriteLine("Unmatched: " + dictionary[key]); } Console.WriteLine("TOTAL: " + totalCount); }
public void Execute() { webServiceType = ModuleDefinition.ImportReference(typeof(WebService)); taskBaseType = ModuleDefinition.ImportReference(typeof(Task)); taskOpenType = ModuleDefinition.ImportReference(typeof(Task <>)); iAsyncResultType = ModuleDefinition.ImportReference(typeof(IAsyncResult)); asyncCallbackType = ModuleDefinition.ImportReference(typeof(AsyncCallback)); taskCompletionSourceType = ModuleDefinition.ImportReference(typeof(TaskCompletionSource <>)); objectCtor = ModuleDefinition.ImportReference(typeof(object).GetConstructor(new Type[0])); iEnumerableExceptionType = ModuleDefinition.ImportReference(typeof(IEnumerable <Exception>)); aggregateExceptionType = ModuleDefinition.ImportReference(typeof(AggregateException)); get_InnerExceptionsMethod = ModuleDefinition.ImportReference(typeof(AggregateException).GetMethod("get_InnerExceptions", new Type[0])); task_get_IsFaultedMethod = new MethodReference("get_IsFaulted", ModuleDefinition.TypeSystem.Boolean, taskBaseType) { HasThis = true }; task_get_ExceptionMethod = new MethodReference("get_Exception", aggregateExceptionType, taskBaseType) { HasThis = true }; task_get_IsCanceledMethod = new MethodReference("get_IsCanceled", ModuleDefinition.TypeSystem.Boolean, taskBaseType) { HasThis = true }; task_WaitMethod = new MethodReference("Wait", ModuleDefinition.TypeSystem.Void, taskBaseType) { HasThis = true }; asyncCallbackInvokeMethod = new MethodReference("Invoke", ModuleDefinition.TypeSystem.Void, asyncCallbackType) { HasThis = true }; asyncCallbackInvokeMethod.Parameters.Add(new ParameterDefinition(iAsyncResultType)); actionOpenType = ModuleDefinition.ImportReference(typeof(Action <>)); get_InnerExceptionMethod = ModuleDefinition.ImportReference(typeof(Exception).GetMethod("get_InnerException", new Type[0])); exceptionDispatchInfoCaptureMethod = ModuleDefinition.ImportReference( ((Func <Exception, ExceptionDispatchInfo>)ExceptionDispatchInfo.Capture).Method); exceptionDispatchInfoThrowMethod = new MethodReference("Throw", ModuleDefinition.TypeSystem.Void, exceptionDispatchInfoCaptureMethod.DeclaringType) { HasThis = true }; generatedCodeAttributeCtor = ModuleDefinition.ImportReference( typeof(GeneratedCodeAttribute).GetConstructor(new Type[] { typeof(string), typeof(string) })); generatedCodeAttr = new CustomAttribute(generatedCodeAttributeCtor); generatedCodeAttr.ConstructorArguments.Add( // tool new CustomAttributeArgument(ModuleDefinition.TypeSystem.String, "AspNetLegacyWebServiceAsync.Fody")); generatedCodeAttr.ConstructorArguments.Add( // version new CustomAttributeArgument(ModuleDefinition.TypeSystem.String, Assembly.GetExecutingAssembly().GetName().Version.ToString())); var debuggerStepThroughCtor = ModuleDefinition.ImportReference( typeof(DebuggerStepThroughAttribute).GetConstructor(new Type[0])); debuggerStepThroughAttr = new CustomAttribute(debuggerStepThroughCtor); var orgTypes = ModuleDefinition.Types.ToList(); foreach (var type in orgTypes) { if (IsDescendedFrom(webServiceType, type)) { ModifyWebService(type); } } }
protected override void Load(ContainerBuilder builder) { var assembly = Assembly.GetExecutingAssembly(); builder.RegisterType <CoreDbContext>() .As <IDbContext>() .InstancePerLifetimeScope(); IEndpointInstance endpointInstance = null; builder.Register(c => endpointInstance) .As <IEndpointInstance>() .SingleInstance(); #region Resources builder.RegisterType <ResourceService <SharedResource> >() .As <IResourceService <SharedResource> >() .InstancePerLifetimeScope(); builder.RegisterType <ResourceService <GhmCoreResource> >() .As <IResourceService <GhmCoreResource> >() .InstancePerLifetimeScope(); #endregion builder.RegisterType <TenantPageRepository>() .As <ITenantPageRepository>() .InstancePerLifetimeScope(); builder.RegisterType <ProfileRepository>() .As <IProfileService>() .InstancePerLifetimeScope(); builder.RegisterType <ClientRepository>() .As <IClientRepository>() .InstancePerLifetimeScope(); builder.RegisterType <ClientAllowedCorsOriginsRepository>() .As <IClientAllowedCorsOriginsRepository>() .InstancePerLifetimeScope(); builder.RegisterType <ClientAllowedGrantTypeRepository>() .As <IClientAllowedGrantTypeRepository>() .InstancePerLifetimeScope(); builder.RegisterType <ClientClaimRepository>() .As <IClientClaimRepository>() .InstancePerLifetimeScope(); builder.RegisterType <ClientIdentityProviderRestrictionRepository>() .As <IClientIdentityProviderRestrictionRepository>() .InstancePerLifetimeScope(); builder.RegisterType <ClientPostLogoutRedirectUrisRepository>() .As <IClientPostLogoutRedirectUrisRepository>() .InstancePerLifetimeScope(); builder.RegisterType <ClientPropertyRepository>() .As <IClientPropertyRepository>() .InstancePerLifetimeScope(); builder.RegisterType <ClientRedirectUrisRepository>() .As <IClientRedirectUrisRepository>() .InstancePerLifetimeScope(); builder.RegisterType <ClientSecretRepository>() .As <IClientSecretRepository>() .InstancePerLifetimeScope(); builder.RegisterType <ClientAllowedScopeRepository>() .As <IClientAllowedScopesRepository>() .InstancePerLifetimeScope(); builder.RegisterType <UserAccountRepository>() .As <IUserAccountRepository>() .InstancePerLifetimeScope(); builder.RegisterType <PageRepository>() .As <IPageRepository>() .InstancePerLifetimeScope(); builder.RegisterType <PageTranslationRepository>() .As <IPageTranslationRepository>() .InstancePerLifetimeScope(); builder.RegisterType <ProvinceRepository>() .As <IProvinceRepository>() .InstancePerLifetimeScope(); builder.RegisterType <TenantRepository>() .As <ITenantRepository>() .InstancePerLifetimeScope(); builder.RegisterType <UserRoleRepository>() .As <IUserRoleRepository>() .InstancePerLifetimeScope(); builder.RegisterType <RolePageRepository>() .As <IRolePageRepository>() .InstancePerLifetimeScope(); builder.RegisterType <RoleRepository>() .As <IRoleRepository>() .InstancePerLifetimeScope(); builder.RegisterType <LanguageRepository>() .As <ILanguageRepository>() .InstancePerLifetimeScope(); builder.RegisterType <TenantLanguageRepository>() .As <ITenantLanguageRepository>() .InstancePerLifetimeScope(); builder.RegisterType <UserPermissionRepository>() .As <IUserPermissionRepository>() .InstancePerLifetimeScope(); builder.RegisterType <UserSettingRepository>() .As <IUserSettingRepository>() .InstancePerLifetimeScope(); builder.RegisterType <EthnicRepository>() .As <IEthnicRepository>() .InstancePerLifetimeScope(); builder.RegisterType <ReligionRepository>() .As <IReligionRepository>() .InstancePerLifetimeScope(); builder.RegisterType <TagRepository>() .As <ITagRepository>() .InstancePerLifetimeScope(); builder.RegisterType <SubjectTagRepository>() .As <ISubjectTagRepository>() .InstancePerLifetimeScope(); builder.RegisterType <ApproverConfigRepository>() .As <IApproverConfigRepository>() .InstancePerLifetimeScope(); #region Resource Service. builder.RegisterType <ResourceService <SharedResource> >() .As <IResourceService <SharedResource> >() .InstancePerLifetimeScope(); builder.RegisterType <ResourceService <GhmCoreResource> >() .As <IResourceService <GhmCoreResource> >() .InstancePerLifetimeScope(); #endregion #region Services builder.RegisterAssemblyTypes(assembly) .Where(t => t.Name.EndsWith("Service")) .AsImplementedInterfaces(); #endregion }
public FsmStateMachine(XmlDocument xmlDoc) { this.states = new Dictionary <string, State>(); XmlNode root = xmlDoc.SelectSingleNode("StateMachine"); fsmName = root.Attributes["name"].Value; XmlNodeList states = root.SelectNodes("State"); for (int i = 0, size = states.Count; i < size; i++) { XmlNode stateNode = states[i]; State state = new State(stateNode.Attributes["name"].Value); state.isDefault = stateNode.Attributes["isDefault"].Value == "true"; XmlNodeList actions = stateNode.SelectSingleNode("Actions").SelectNodes("Action"); for (int j = 0; j < actions.Count; j++) { XmlNode actionNode = actions[j]; string className = actionNode.Attributes["name"].Value; FSMAction action = (FSMAction)Reflection.GetExecutingAssembly().CreateInstance(className); action.name = className; XmlNodeList paramsNodes = actionNode.SelectSingleNode("params").SelectNodes("param"); for (int k = 0; k < paramsNodes.Count; k++) { XmlNode paramNode = paramsNodes[k]; string propertyName = paramNode.Attributes["key"].Value; Type tp = action.GetType(); FieldInfo pInfo = tp.GetField(propertyName); if (null == pInfo) { UnityEngine.Debug.LogError("获取条件名为: " + action.name + "的属性 " + paramNode.Attributes["key"].Value + "不存在"); return; } pInfo.SetValue(action, paramNode.Attributes["value"].Value); } state.AddAction(action); } XmlNodeList transitions = stateNode.SelectSingleNode("Transitions").SelectNodes("Transition"); for (int j = 0; j < transitions.Count; j++) { XmlNode transitionNode = transitions[j]; Transition trans = new Transition(transitionNode.Attributes["name"].Value, state.name, transitionNode.Attributes["toState"].Value); XmlNodeList conditionsNodes = transitionNode.SelectSingleNode("Conditions").SelectNodes("Condition"); for (int k = 0; k < conditionsNodes.Count; k++) { XmlNode conditionNode = conditionsNodes[k]; string className = conditionNode.Attributes["name"].Value; FSMCondition condition = (FSMCondition)Reflection.GetExecutingAssembly().CreateInstance(className); condition.name = className; XmlNodeList paramsNodes = conditionNode.SelectSingleNode("params").SelectNodes("param"); for (int m = 0; m < paramsNodes.Count; m++) { XmlNode paramNode = paramsNodes[m]; FieldInfo pInfo = condition.GetType().GetField(paramNode.Attributes["key"].Value); if (null == pInfo) { UnityEngine.Debug.LogError("获取条件名为: " + condition.name + "的属性 " + paramNode.Attributes["key"].Value + "不存在"); return; } // UnityEngine.Debug.Log("获取条件名为: " + condition.name + "的属性 " + paramNode.Attributes["key"].Value + "不存在"); pInfo.SetValue(condition, paramNode.Attributes["value"].Value); } trans.AddCondition(condition); } state.AddTransition(trans); } AddState(state); } }
public void RunTest(Generator test, bool exe, string testName = null) { if (test == null) { throw new ArgumentNullException(nameof(test)); } testName = testName ?? GetTestName(test); Console.WriteLine(">>> GEN {0}", testName); string name = testName; string exeDir = string.Empty; string exeFilePath = string.Empty; if (exe) { exeDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); exeFilePath = Path.Combine(exeDir, name + ".exe"); Directory.CreateDirectory(exeDir); } AssemblyGen asm; asm = !exe ? new AssemblyGen(name, new CompilerOptions()) : new AssemblyGen(name, new CompilerOptions() { OutputPath = exeFilePath }); test(asm); if (exe) { asm.Save(); PEVerify.AssertValid(exeFilePath); } Console.WriteLine("=== RUN {0}", testName); string[] testArguments = GetTestArguments(test); bool useReflectionEntryPoint = !exe; #if NET5_0 useReflectionEntryPoint = true; #endif #if !FEAT_IKVM if (useReflectionEntryPoint) { #if SILVERLIGHT || NET5_0 Type entryType = asm.GetAssembly().DefinedTypes.First(t => t.GetMethod("Main", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic) != null); #else Type entryType = ((TypeBuilder)asm.GetAssembly().EntryPoint.DeclaringType).CreateType(); #endif MethodInfo entryMethod = entryType.GetMethod(asm.GetAssembly().EntryPoint?.Name ?? "Main", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); object[] entryArgs = null; if (entryMethod.GetParameters().Length == 1) { entryArgs = new object[] { testArguments }; } entryMethod.Invoke(null, entryArgs); } else #endif { try { AppDomain.CurrentDomain.ExecuteAssembly(exeFilePath, testArguments); } catch (System.BadImageFormatException) { throw; } catch (AppDomainUnloadedException) { throw; } catch (Exception e) { #if SILVERLIGHT throw; #else throw new TargetInvocationException(e); #endif } } Console.WriteLine("<<< END {0}", testName); Console.WriteLine(); if (exe) { try { File.Delete(exeFilePath); } catch { } } }
/// <summary> /// バージョン文字列を取得 /// </summary> /// <returns>バージョン文字列</returns> public static string GetVersionString() { return(SRA.GetExecutingAssembly().GetName().Version.ToString()); }