/// <summary> /// Invoked when the forge is enabled. We us this to set all the components /// we require for our forge. /// </summary> protected void SetupComponents() { // Removed null entries (script changes can make this happen) for (int i = m_Components.Count - 1; i >= 0; i--) { if (m_Components[i] == null) { m_Components.RemoveAt(i); } } // Get our current type Type forgeType = GetType(); // Get the attribute RequiredWidgetComponetsAttribute requiredWidgets = Attribute.GetCustomAttribute(forgeType, typeof(RequiredWidgetComponetsAttribute)) as RequiredWidgetComponetsAttribute; // Keep a reference to our list of components so we can remove them at the end if their are extra List <ForgeComponent> componentList = new List <ForgeComponent>(m_Components); // If it's not null if (requiredWidgets != null) { // Loop over all required types foreach (Type requiredType in requiredWidgets.requiredTypes) { // Set a flag to see if we have a match. bool foundType = false; // Loop over all components for (int i = componentList.Count - 1; i >= 0; i--) { // Check if the type matches if (componentList[i].GetType() == requiredType) { // We have a match. foundType = true; componentList.RemoveAt(i); break; } } // If we did not find a match we have to create one if (!foundType) { // Create the instance. ForgeComponent component = CreateInstance(requiredType) as ForgeComponent; // Add it to our list m_Components.Add(component); } } } // Any components still left in the list are extra and should be removed for (int i = 0; i < componentList.Count; i++) { // Remove it. m_Components.Remove(componentList[i]); // Destroy the scriptable object. DestroyImmediate(componentList[i], true); } componentList = null; }
public AnnotationDecoration(System.Attribute ann, Net.Vpc.Upa.Config.DecorationSourceType locationType, Net.Vpc.Upa.Config.DecorationTarget targetType, string type, string location, int position, Net.Vpc.Upa.Config.ConfigInfo configInfo) { this.ann = ann; this.decorationSourceType = locationType; this.targetType = targetType; this.type = type; this.location = location; this.configInfo = configInfo; this.position = position; }
private bool IsAppScoped(SettingsProperty property) { foreach (DictionaryEntry entry in property.Attributes) { System.Attribute attrib = (System.Attribute)entry.Value; if (attrib is System.Configuration.ApplicationScopedSettingAttribute) { return(true); } } return(false); }
public static OptionSetMetadataAttribute GetMetadata <T>(this T value) where T : struct, System.IConvertible { System.Type enumType = typeof(T); if (!enumType.IsEnum) { throw new System.ArgumentException("T must be an enum!"); } System.Reflection.MemberInfo[] members = enumType.GetMember(value.ToString()); for (int i = 0; (i < members.Length); i++ ) { System.Attribute attribute = System.Reflection.CustomAttributeExtensions.GetCustomAttribute(members[i], typeof(OptionSetMetadataAttribute)); if (attribute != null) { return((OptionSetMetadataAttribute)(attribute)); } } throw new System.ArgumentException("T must be an enum adorned with an OptionSetMetadataAttribute!"); }
public RedisCacheAttributes(RedisResource cache, string resourceGroupName) { Id = cache.Id; Location = cache.Location; Name = cache.Name; Type = cache.Type; HostName = cache.HostName; Port = cache.Port.HasValue ? cache.Port.Value : 0; ProvisioningState = cache.ProvisioningState; SslPort = cache.SslPort.HasValue ? cache.SslPort.Value : 0; EnableNonSslPort = cache.EnableNonSslPort.Value; RedisVersion = cache.RedisVersion; Size = SizeConverter.GetSizeInUserSpecificFormat(cache.Sku.Family, cache.Sku.Capacity); Sku = cache.Sku.Name; ResourceGroupName = resourceGroupName; SubnetId = cache.SubnetId; StaticIP = cache.StaticIP; TenantSettings = cache.TenantSettings; ShardCount = cache.ShardCount; MinimumTlsVersion = cache.MinimumTlsVersion; Tag = cache.Tags; Zone = cache.Zones; RedisConfiguration = new Dictionary <string, string>(); // Converting cache.RedisConfiguration Object into a readable dictionary using the json attributes if (cache.RedisConfiguration != null) { foreach (PropertyInfo property in cache.RedisConfiguration.GetType().GetProperties()) { System.Attribute attr = property.GetCustomAttribute(typeof(JsonPropertyAttribute)); if (property.GetValue(cache.RedisConfiguration) != null && attr != null) { JsonPropertyAttribute jsonAttr = (JsonPropertyAttribute)attr; RedisConfiguration[jsonAttr.PropertyName] = (string)property.GetValue(cache.RedisConfiguration); } } if (cache.RedisConfiguration.AdditionalProperties != null) { foreach (KeyValuePair <string, object> kvPair in cache.RedisConfiguration.AdditionalProperties) { RedisConfiguration[kvPair.Key] = (string)kvPair.Value; } } } // Converting cache.Identity Object into a readable SystemAssignedIdenty dictionary and UserAssignedIdentities list if (cache.Identity != null) { IdentityType = ""; if (cache.Identity.PrincipalId != null) { SystemAssignedIdentity = new Dictionary <string, string> { { nameof(cache.Identity.PrincipalId), cache.Identity.PrincipalId.ToString() }, { nameof(cache.Identity.TenantId), cache.Identity.TenantId.ToString() } }; IdentityType = nameof(ManagedServiceIdentityType.SystemAssigned); } if (cache.Identity.UserAssignedIdentities?.Count > 0) { UserAssignedIdentity = new List <string>(); foreach (var identity in cache.Identity.UserAssignedIdentities) { UserAssignedIdentity.Add(identity.Key); } if (nameof(ManagedServiceIdentityType.SystemAssigned).Equals(IdentityType)) { IdentityType = nameof(ManagedServiceIdentityType.SystemAssignedUserAssigned); } else { IdentityType = nameof(ManagedServiceIdentityType.UserAssigned); } } } }
public bool Matches(System.Attribute attribute) { }
public bool Contains(System.Attribute attribute) { }
/// <summary> /// Reads the yaml defined on disk if there is one for a Scriptable Forge or /// creates a new one. /// </summary> private static void ReadInstanceFromDiskOrCreateNew() { // Store our path string savePath = GetSavePath(); ScriptableForge m_Instance = null; List <Widget> m_LoadedWidgets = new List <Widget>(); // Does it exist already? if (File.Exists(savePath)) { // It does so lets load it Object[] loadedObject = InternalEditorUtility.LoadSerializedFileAndForget(savePath); // Loop over all our objects and find the one we care about (There should really only be one) for (int i = 0; i < loadedObject.Length; i++) { if (loadedObject[i] is ScriptableForge) { // Save our instance m_Instance = loadedObject[i] as ScriptableForge; } else { if (loadedObject[i] is Widget) { m_LoadedWidgets.Add(loadedObject[i] as Widget); } } } } else { // We don't have a save file so we create a new one. m_Instance = CreateInstance <ScriptableForge>(); } // Initialize all the widgets. for (int i = 0; i < m_LoadedWidgets.Count; i++) { m_LoadedWidgets[i].Initalize(m_Instance); } // Sort them in order. m_LoadedWidgets.Sort(); // Save them back to our instance. m_Instance.Widgets = m_LoadedWidgets; // Regenerate Widgets if they are set to auto build. for (int i = 0; i < m_LoadedWidgets.Count; i++) { m_LoadedWidgets[i].OnLoaded(); } // Get all our widget types. List <Type> widgetTypes = GetDefinedWidgetTypes(includeAbstractTypes: false); // Remove all that are not required. for (int i = widgetTypes.Count - 1; i >= 0; i--) { if (Attribute.GetCustomAttribute(widgetTypes[i], typeof(RequiredWidgetAttribute)) != null) { bool foundWidget = false; for (int x = 0; x < m_LoadedWidgets.Count; x++) { if (m_LoadedWidgets[x].GetType() == widgetTypes[i]) { foundWidget = true; // We found the type so we move on. break; } } if (!foundWidget) { m_Instance.OnWidgetAdded(widgetTypes[i]); } } } }
public static bool IsAcceptableAsRole(System.Attribute primitiveRoleSetAttr) { var roleSetAttr = (IRoleSetAttribute)primitiveRoleSetAttr; return(roleSetAttr.IsAcceptable()); }
public override bool OnGUI(SerializedProperty property, SerializedProperty overrideState, GUIContent title, System.Attribute attribute) { MinMaxRangeAttribute range = attribute as MinMaxRangeAttribute; SerializedProperty minRange = property.FindPropertyRelative("minValue"); SerializedProperty maxRange = property.FindPropertyRelative("maxValue"); float minValue = minRange.floatValue; float maxValue = maxRange.floatValue; Rect startRect = EditorGUILayout.GetControlRect(); Rect minRect = new Rect(EditorGUIUtility.labelWidth + EditorGUIUtility.fieldWidth * 0.7f, startRect.y, EditorGUIUtility.fieldWidth, startRect.height); float p = minRect.x + EditorGUIUtility.standardVerticalSpacing * 2f + EditorGUIUtility.fieldWidth; Rect sliderRect = new Rect(p, startRect.y, EditorGUIUtility.currentViewWidth - p - EditorGUIUtility.fieldWidth * 1.5f, startRect.height); Rect maxRect = new Rect(sliderRect.x + sliderRect.width + EditorGUIUtility.standardVerticalSpacing * 2f, startRect.y, EditorGUIUtility.fieldWidth, startRect.height); EditorGUI.LabelField(startRect, title.text); minValue = EditorGUI.FloatField(minRect, minValue); EditorGUI.MinMaxSlider(sliderRect, ref minValue, ref maxValue, range.minLimit, range.maxLimit); maxValue = EditorGUI.FloatField(maxRect, maxValue); minRange.floatValue = minValue; maxRange.floatValue = maxValue; return(true); }
public UnitTestingData(string methodName, System.Attribute attribute) { m_methodName = methodName; m_attribute = attribute; }
public AnnotationDecoration(System.Attribute ann, Net.Vpc.Upa.Config.DecorationSourceType locationType, Net.Vpc.Upa.Config.DecorationTarget targetType, string type, string location, int position) : this(ann, locationType, targetType, type, location, position, null) { }
public StringBuilder VisitAttribute(System.Attribute attribute, int data) { throw new SLSharpException("SL# does not have attributes."); }