Пример #1
0
        private static bool IsScaffoldColumn(CodeProperty propertyType)
        {
            bool        flag;
            IEnumerator enumerator = propertyType.Attributes.GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    CodeAttribute current = (CodeAttribute)enumerator.Current;
                    if (!string.Equals(current.FullName, TypeNames.ScaffoldColumnAttributeTypeName, StringComparison.Ordinal))
                    {
                        continue;
                    }
                    flag = CodeModelPropertyMetadata.IsPropertyValuePresent(current, string.Empty, "true");
                    return(flag);
                }
                return(true);
            }
            finally
            {
                IDisposable disposable = enumerator as IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }
            return(flag);
        }
Пример #2
0
 public CodeModelPropertyMetadata(CodeProperty property)
 {
     if (property == null)
     {
         throw new ArgumentNullException("property");
     }
     base.PropertyName    = property.Name;
     base.TypeName        = property.Type.AsFullName;
     base.ShortTypeName   = property.Type.AsString;
     base.IsPrimaryKey    = CodeModelPropertyMetadata.IsPropertyPrimaryKey(property);
     base.IsAutoGenerated = base.IsPrimaryKey;
     base.IsReadOnly      = !CodePropertyExtensions.HasPublicSetter(property);
     base.Scaffold        = CodeModelPropertyMetadata.IsScaffoldColumn(property);
 }
Пример #3
0
        private static bool IsPropertyPrimaryKey(CodeProperty propertyType)
        {
            bool flag;

            if (string.Equals(propertyType.Name, "id", StringComparison.OrdinalIgnoreCase))
            {
                return(true);
            }
            if (string.Equals(propertyType.Name, string.Concat(propertyType.Parent.Name, "id"), StringComparison.OrdinalIgnoreCase))
            {
                return(true);
            }
            IEnumerator enumerator = propertyType.Attributes.GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    CodeAttribute current = (CodeAttribute)enumerator.Current;
                    if (string.Equals(current.FullName, TypeNames.KeyAttributeTypeName, StringComparison.Ordinal))
                    {
                        flag = true;
                        return(flag);
                    }
                    else if (!string.Equals(current.FullName, TypeNames.EdmScalarPropertyAttributeTypeName, StringComparison.Ordinal) || !CodeModelPropertyMetadata.IsPropertyValuePresent(current, "EntityKeyProperty", "true"))
                    {
                        if (!string.Equals(current.FullName, TypeNames.ColumnAttributeTypeName, StringComparison.Ordinal) || !CodeModelPropertyMetadata.IsPropertyValuePresent(current, "IsPrimaryKey", "true"))
                        {
                            continue;
                        }
                        flag = true;
                        return(flag);
                    }
                    else
                    {
                        flag = true;
                        return(flag);
                    }
                }
                return(false);
            }
            finally
            {
                IDisposable disposable = enumerator as IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }
            return(flag);
        }