Beispiel #1
0
 public virtual void RunBuild(FilePath solution)
 {
     CakeContext.DotNetBuild(solution, c => {
         c.Configuration = Configuration;
         if (!string.IsNullOrEmpty(Platform))
         {
             c.Properties ["Platform"] = new [] { Platform }
         }
         ;
         if (Targets != null && Targets.Any())
         {
             foreach (var t in Targets)
             {
                 c.Targets.Add(t);
             }
         }
         if (Properties != null && Properties.Any())
         {
             foreach (var kvp in Properties)
             {
                 c.Properties.Add(kvp.Key, kvp.Value);
             }
         }
     });
 }
Beispiel #2
0
        protected override int Compare <T>(T other)
        {
            if (!(other is YumlClassWithDetails))
            {
                return(-1);
            }

            var o = other as YumlClassWithDetails;

            int basicCompare = GetName() == o.GetName() && BackGroundColour == o.BackGroundColour ? 0 : 1;

            if (basicCompare != 0)
            {
                return(basicCompare);
            }

            if (Notes.Any(note => !o.Notes.Contains(note)))
            {
                return(-1);
            }

            if (Methods.Any(method => !o.Methods.Contains(method)))
            {
                return(-1);
            }

            if (Properties.Any(property => !o.Properties.Contains(property)))
            {
                return(-1);
            }

            return(basicCompare);
        }
Beispiel #3
0
 private void GuardForDuplicatePropertyMap(PropertyMap result)
 {
     if (Properties.Any(p => p.Name.Equals(result.Name)))
     {
         throw new ArgumentException($"Duplicate mapping for property {result.Name} detected.");
     }
 }
Beispiel #4
0
        /// <summary>
        /// Test for if <see cref="someMember"/> belongs to this instance.
        /// </summary>
        /// <param name="someMember"></param>
        /// <returns></returns>
        public bool ContainsThisMember(CgMember someMember)
        {
            if (someMember == null)
            {
                return(false);
            }
            if (Properties.Any(p => p.Equals(someMember)))
            {
                return(true);
            }
            if (Fields.Any(f => f.Equals(someMember)))
            {
                return(true);
            }
            if (Events.Any(e => e.Equals(someMember)))
            {
                return(true);
            }
            if (Methods.Any(m => m.Equals(someMember)))
            {
                return(true);
            }

            return(false);
        }
Beispiel #5
0
        public string ToString(string solutionFileName)
        {
            var arguments = new List <string>();

            if (Target.IsNotNullOrEmpty())
            {
                arguments.Add($"/target:{Target}");
            }

            if (NoLogo)
            {
                arguments.Add("/nologo");
            }

            if (Switches?.Any() == true)
            {
                arguments.AddRange(Switches.Select(x => $"/{x.Key}{(string.IsNullOrEmpty(x.Value) ? string.Empty : $":{x.Value}")}"));
            }

            if (Properties?.Any() == true)
            {
                arguments.AddRange(Properties.Select(property => $"/property:{property.Key}=\"{property.Value}\""));
            }

            arguments.Add(solutionFileName);

            return(string.Join(" ", arguments));
        }
Beispiel #6
0
        protected virtual void AutoMap(Func <Type, PropertyInfo, bool> canMap)
        {
            Type        type          = typeof(T);
            bool        hasDefinedKey = Properties.Any(p => p.KeyType != KeyType.NotAKey);
            PropertyMap keyMap        = null;

            foreach (var propertyInfo in type.GetProperties())
            {
                if (Properties.Any(p => p.Name.Equals(propertyInfo.Name, StringComparison.InvariantCultureIgnoreCase)))
                {
                    continue;
                }

                if ((canMap != null && !canMap(type, propertyInfo)))
                {
                    continue;
                }

                PropertyMap map = Map(propertyInfo);
                if (!hasDefinedKey)
                {
                    if (IsAttributeExist(map.PropertyInfo, typeof(KeyAttribute)))
                    {
                        keyMap = map;
                    }
                }
            }

            if (keyMap != null)
            {
                keyMap.Key(PropertyTypeKeyTypeMapping.ContainsKey(keyMap.PropertyInfo.PropertyType)
                    ? PropertyTypeKeyTypeMapping[keyMap.PropertyInfo.PropertyType]
                    : KeyType.Assigned);
            }
        }
Beispiel #7
0
        /// <summary>
        /// Gets the number of dimensions.
        /// </summary>
        /// <param name="withoutLabels">if set to <c>true</c> [without labels].</param>
        /// <returns></returns>
        public Int32 GetNumberOfDimensions(Boolean withoutLabels = true)
        {
            Int32 c = 0;

            if (Properties.Any())
            {
                foreach (var p in Properties)
                {
                    c += p.GetNumberOfDimensions(withoutLabels);
                }
            }
            else
            {
                if (!withoutLabels)
                {
                    if (!LabelXPathRelative.isNullOrEmpty())
                    {
                        c++;
                    }
                }
                if (!DataXPathRelative.isNullOrEmpty())
                {
                    c++;
                }
            }

            return(c);
        }
Beispiel #8
0
        void AddProperties(Method method, CodeGenerationOptions opt)
        {
            foreach (var p in method.Parameters)
            {
                if (p.IsSender)
                {
                    continue;
                }

                // We've already added this property from a different overload
                if (Properties.Any(prop => prop.Name == p.PropertyName))
                {
                    continue;
                }

                Fields.Add(new FieldWriter {
                    Name = opt.GetSafeIdentifier(p.Name),
                    Type = new TypeReferenceWriter(opt.GetTypeReferenceName(p))
                });

                var prop = new PropertyWriter {
                    Name         = p.PropertyName,
                    PropertyType = new TypeReferenceWriter(opt.GetTypeReferenceName(p)),
                    IsPublic     = true,
                    HasGet       = true
                };

                prop.GetBody.Add($"return {opt.GetSafeIdentifier (p.Name)};");

                Properties.Add(prop);
            }
        }
Beispiel #9
0
        /// <summary>
        /// Gets all the file paths found on all the members PDB data
        /// </summary>
        public string[] GetMySrcCodeFiles()
        {
            var allMembers = new List <CgMember>();

            if (Properties != null && Properties.Any())
            {
                allMembers.AddRange(Properties);
            }
            if (Events != null && Events.Any())
            {
                allMembers.AddRange(Events);
            }
            if (Methods != null && Methods.Any())
            {
                allMembers.AddRange(Methods);
            }
            if (Fields != null && Fields.Any())
            {
                allMembers.AddRange(Fields);
            }

            var srcCodeFiles = new HashSet <string>();

            foreach (var cgMem in allMembers)
            {
                if (cgMem?.PdbModuleSymbols?.file == null)
                {
                    continue;
                }

                srcCodeFiles.Add(cgMem.PdbModuleSymbols.file);
            }

            return(srcCodeFiles.ToArray());
        }
Beispiel #10
0
        protected virtual void AutoMap(Func <Type, PropertyInfo, bool> canMap)
        {
            Type        type          = typeof(T);
            bool        hasDefinedKey = Properties.Any(p => p.Value.KeyType != KeyType.NotAKey);
            PropertyMap keyMap        = null;
            var         infos         = type.GetProperties();
            //处理字段的的属性
            var keyInfo = infos.FirstOrDefault(t => (t.GetCustomAttributes(typeof(DbColumnAttribute)).Any()));// 获取主键
            var keyStr  = keyInfo?.Name ?? "Id";
            var tempkey = type.GetCustomAttributeValue <DbColumnAttribute>(x => x.IsKey.ToString(), keyInfo.Name);

            foreach (PropertyMap map in from propertyInfo in infos where !Properties.Any(p => p.Value.Name.Equals(propertyInfo.Name, StringComparison.InvariantCultureIgnoreCase)) where (canMap == null || canMap(type, propertyInfo)) select Map(propertyInfo) into map where !hasDefinedKey select map)
            {
                if (string.Equals(map.PropertyInfo.Name, "id", StringComparison.InvariantCultureIgnoreCase))
                {
                    keyMap = map;
                }
                else if (keyMap == null && map.PropertyInfo.Name.EndsWith("id", true, CultureInfo.InvariantCulture))
                {
                    keyMap = map;
                }
            }

            //if (keyMap != null)
            //{
            //    //设置自增
            //    keyMap.Key(_propertyTypeKeyTypeMapping.ContainsKey(keyMap.PropertyInfo.PropertyType)
            //        ? _propertyTypeKeyTypeMapping[keyMap.PropertyInfo.PropertyType]
            //        : KeyType.Assigned);
            //}
        }
        public bool IsValid()
        {
            bool valid = !string.IsNullOrEmpty(FileRelativePath) &&
                         !Properties.Any(p => !p.IsValid());

            return(valid);
        }
Beispiel #12
0
        public override void RunBuild(FilePath solution)
        {
            if (!BuildsOnCurrentPlatform)
            {
                CakeContext.Information("Solution is not configured to build on this platform: {0}", SolutionPath);
                return;
            }

            CakeContext.MSBuild(solution, c => {
                c.Configuration   = Configuration;
                c.MSBuildPlatform = MSBuildPlatform;

                if (!string.IsNullOrEmpty(Platform))
                {
                    c.Properties["Platform"] = new[] { Platform }
                }
                ;

                if (Targets != null && Targets.Any())
                {
                    foreach (var t in Targets)
                    {
                        c.Targets.Add(t);
                    }
                }

                if (Properties != null && Properties.Any())
                {
                    foreach (var kvp in Properties)
                    {
                        c.Properties.Add(kvp.Key, kvp.Value);
                    }
                }
            });
        }
Beispiel #13
0
        public IEnumerable <PythonType> GetUsedTypes()
        {
            var types = new HashSet <PythonType>();

            // Parse types recursively to properly return deep generics
            var typesToProcess = new Queue <PythonType>(GetUsedTypesToIterateOver());

            while (typesToProcess.Count > 0)
            {
                var currentType = typesToProcess.Dequeue();

                types.Add(currentType);

                foreach (var typeParameter in currentType.TypeParameters)
                {
                    typesToProcess.Enqueue(typeParameter);
                }
            }

            // Python classes with type parameters always extend typing.Generic[T, ...] where T = typing.TypeVar('T')
            if (Type.TypeParameters.Count > 0)
            {
                types.Add(new PythonType("Generic", "typing"));
                types.Add(new PythonType("TypeVar", "typing"));
            }

            // PropertyRenderer adds the @abc.abstractmethod decorator to abstract properties
            if (Properties.Any(p => !p.Static && p.Abstract))
            {
                types.Add(new PythonType("abstractmethod", "abc"));
            }

            // PropertyRenderer adds warnings.warn() to deprecated non-static properties
            if (Properties.Any(p => p.DeprecationReason != null && !p.Static))
            {
                types.Add(new PythonType("warn", "warnings"));
            }

            // MethodRenderer adds the @typing.overload decorator to overloaded methods
            if (Methods.Any(m => m.Overload))
            {
                types.Add(new PythonType("overload", "typing"));
            }

            // MethodRenderer adds warnings.warn() to non-overloaded deprecated methods
            if (Methods.Any(m => m.DeprecationReason != null && !m.Overload))
            {
                types.Add(new PythonType("warn", "warnings"));
            }

            foreach (var innerClass in InnerClasses)
            {
                foreach (var usedType in innerClass.GetUsedTypes())
                {
                    types.Add(usedType);
                }
            }

            return(types);
        }
Beispiel #14
0
 protected void GuardForDuplicatePropertyMap(PropertyMap result)
 {
     if (Properties.Any(p => p.Name.Equals(result.Name)))
     {
         throw new ArgumentException(string.Format("Duplicate mapping for property {0} detected.", result.Name));
     }
 }
        /// <summary>
        /// Creates a log layout.
        /// </summary>
        /// <returns>
        /// Returns a json layout that will be used to render logs.
        /// </returns>
        private JsonLayout CreateLayout()
        {
            var jsonLayout = new JsonLayout
            {
                Attributes =
                {
                    new JsonAttribute("timestamp",       "${longdate}"),
                    new JsonAttribute("level",           "${level:upperCase=true}"),
                    new JsonAttribute("message",         "${message}"),
                    new JsonAttribute("exception",       new JsonLayout
                    {
                        Attributes =
                        {
                            new JsonAttribute("type",    "${exception:format=Type}"),
                            new JsonAttribute("message", ExceptionLayout),
                        },
                        RenderEmptyObject = false
                    },
                                      false)
                }
            };

            if (Properties.Any())
            {
                var propertyLayout = new JsonLayout();
                foreach (var prop in Properties)
                {
                    propertyLayout.Attributes.Add(new JsonAttribute(prop.Name, prop.Value));
                }
                jsonLayout.Attributes.Add(new JsonAttribute("properties", propertyLayout, false));
            }

            return(jsonLayout);
        }
 private void GuardForDuplicatePropertyMap(PropertyMap result)
 {
     if (Properties.Any(p => p != null && p.Name.Equals(result.Name)))
     {
         throw new ArgumentException(string.Format("属性{0}发现多个映射配置。 ", result.Name));
     }
 }
Beispiel #17
0
        /// <summary>
        /// Indicates whether the current entity is dirty.
        /// </summary>
        /// <returns>True if entity is dirty, otherwise False</returns>
        public override bool IsDirty()
        {
            bool dirtyEntity = base.IsDirty();

            bool dirtyProperties = Properties.Any(x => x.IsDirty());

            return(dirtyEntity || dirtyProperties);
        }
Beispiel #18
0
 public void AddProperty(PropertyMapping property)
 {
     if (Properties.Any(x => x.Name == property.Name))
     {
         throw new InvalidOperationException("Tried to add property '" + property.Name + "' when already added.");
     }
     AddMapping(property, MappingType.Property);
 }
Beispiel #19
0
 public bool HasProperty(string property)
 {
     if (Properties.Length == 0)
     {
         return(true);
     }
     return(Properties.Any(p => p.value.ToLower() == property.ToLower()));
 }
Beispiel #20
0
 /// <summary>
 /// 获取逻辑删除接口
 /// </summary>
 private string GetISoftDelete()
 {
     if (Properties.Any(t => t.ColumnName == "IsDeleted"))
     {
         return(",IDelete");
     }
     return(string.Empty);
 }
Beispiel #21
0
 /// <summary>
 /// 获取租户接口
 /// </summary>
 private string GetITenant()
 {
     if (Properties.Any(t => t.ColumnName == "TenantId"))
     {
         return(",ITenant");
     }
     return(string.Empty);
 }
Beispiel #22
0
 public JsValue JsToString(LexicalEnvironment lexEnv)
 {
     if (Properties.Any())
     {
         return(JsString.Empty);
     }
     return(new JsString(string.Join(",", Properties.Select(p => p.Value.AsString()))));
 }
Beispiel #23
0
 public bool HasReadOnly()
 {
     if (!hasReadonly.HasValue)
     {
         hasReadonly = Properties != null && Properties.Any(x => x.HasReadOnly());
     }
     return(hasReadonly.Value);
 }
Beispiel #24
0
        protected string ExpandedPropertyTitles()
        {
            if (Properties == null || !Properties.Any())
            {
                return(string.Empty);
            }

            return(string.Join(", ", PropertyTitles));
        }
Beispiel #25
0
        protected Item(JSONProxy.Item item)
        {
            Id            = item.Id;
            Verified      = item.Verified;
            Identified    = item.Identified;
            IsMirrored    = item.Duplicated;
            W             = item.W;
            H             = item.H;
            IconURL       = getIconUrl(item.Icon);
            League        = item.League;
            Name          = item.Name;
            TypeLine      = item.TypeLine;
            DescrText     = item.DescrText;
            X             = item.X;
            Y             = item.Y;
            InventoryId   = item.InventoryId;
            SecDescrText  = item.SecDescrText;
            Explicitmods  = item.ExplicitMods;
            ItemType      = Model.ItemType.UnSet;
            CraftedMods   = item.CraftedMods ?? new List <string>();
            VeiledMods    = item.VeiledMods ?? new List <string>();
            EnchantMods   = item.EnchantMods ?? new List <string>();
            FracturedMods = item.FracturedMods ?? new List <string>();
            FlavourText   = item.FlavourText;
            ItemLevel     = item.Ilvl;
            Shaper        = item.Shaper;
            Elder         = item.Elder;
            Synthesised   = item.Synthesised;
            Fractured     = item.Fractured;
            StackSize     = item.StackSize;
            MaxStackSize  = item.MaxStackSize;

            if (item.Properties != null)
            {
                Properties = item.Properties.Select(p => new Property(p)).ToList();

                if (Properties.Any(p => p.Name == "Quality"))
                {
                    IsQuality = true;
                    Quality   = ProxyMapper.GetQuality(item.Properties);
                }
            }

            Corrupted         = item.Corrupted;
            Microtransactions = item.CosmeticMods ?? new List <string>();
            EnchantMods       = item.EnchantMods ?? new List <string>();

            TradeX           = X;
            TradeY           = Y;
            TradeInventoryId = InventoryId;
            Character        = string.Empty;

            if (item.Elder || item.Shaper)
            {
                BackgroundUrl = ItemBackgroundUrlBuilder.GetUrl(this);
            }
        }
        private void AutoMap()
        {
            Type type = typeof(T);

            string columnPrefix = string.Empty;

            if (Attribute.IsDefined(type, typeof(PrefixForColumnsAttribute)))
            {
                columnPrefix = ((PrefixForColumnsAttribute)type.GetCustomAttribute(typeof(PrefixForColumnsAttribute))).Prefix;
            }

            foreach (PropertyInfo propertyInfo in EntityType.GetProperties())
            {
                PropertyMap propertyMap;
                if (Attribute.IsDefined(propertyInfo, typeof(IgnoreAttribute)))
                {
                    propertyMap = Map(propertyInfo, false).Ignore();
                }
                else if (Attribute.IsDefined(propertyInfo, typeof(ColumnNameAttribute)))
                {
                    propertyMap = Map(propertyInfo, false).Column(((ColumnNameAttribute)propertyInfo.GetCustomAttribute(typeof(ColumnNameAttribute))).Name);
                }
                ////else if (Attribute.IsDefined(propertyInfo, typeof(MapToAttribute)))
                ////    propertyMap = Map(propertyInfo, false).Column(((MapToAttribute)propertyInfo.GetCustomAttribute(typeof(MapToAttribute))).DatabaseColumn);
                else if (!string.IsNullOrEmpty(columnPrefix))
                {
                    propertyMap = Map(propertyInfo, false).Column(string.Format("{0}{1}", columnPrefix, propertyInfo.Name));
                }
                else
                {
                    propertyMap = Map(propertyInfo, false);
                }

                if (Properties.Any(e => e.KeyType != KeyType.NotAKey))
                {
                    continue;
                }

                if (Attribute.IsDefined(propertyInfo, typeof(PrymaryKeyAttribute)))
                {
                    propertyMap.Key(KeyType.PrimaryKey);
                }

                if (Attribute.IsDefined(propertyInfo, typeof(IdentityAttribute)))
                {
                    propertyMap.Key(KeyType.Identity);
                }

                if (!string.IsNullOrEmpty(_identityColumn) && string.Equals(propertyMap.PropertyInfo.Name, _identityColumn, StringComparison.OrdinalIgnoreCase))
                {
                    propertyMap.Key(PropertyTypeKeyTypeMapping.ContainsKey(propertyMap.PropertyInfo.PropertyType) ?
                                    PropertyTypeKeyTypeMapping[propertyMap.PropertyInfo.PropertyType] :
                                    KeyType.Assigned);
                }
            }
        }
Beispiel #27
0
        public string ToFinalString()
        {
            //string result = String.Format("{0} {1} class {2}", AccessModifier, String.Join(" ", Keywords), Name);
            string result = AccessModifier;

            if (Keywords != null && Keywords.Any())
            {
                result += " " + String.Join(" ", Keywords);
            }

            result += " " + Type + " " + Name + " ";

            if (Inheritance != null && Inheritance != "")
            {
                result += " : " + Inheritance;
            }

            if (Interfaces != null && Interfaces.Any())
            {
                if (Inheritance == null || Inheritance == "")
                {
                    result += " : ";
                }
                else
                {
                    result += ", ";
                }
                result += String.Join(", ", Interfaces);
            }

            result += "\n{\n";

            if (Properties != null && Properties.Any())
            {
                foreach (var item in Properties)
                {
                    result += "\t" + item.ToString() + " { get; set; }\n";
                }

                result += "\n";
            }

            if (Methods != null && Methods.Any())
            {
                foreach (var item in Methods)
                {
                    result += item.ToFinalString() + "\n";
                }

                result += "\n";
            }

            result += "}\n";

            return(result);
        }
Beispiel #28
0
 /// <summary>
 /// 是否树型实体
 /// </summary>
 public bool IsTreeEntity()
 {
     if (Properties.Any(t => t.ColumnName == "ParentId") &&
         Properties.Any(t => t.ColumnName == "Path") &&
         Properties.Any(t => t.ColumnName == "Level"))
     {
         return(true);
     }
     return(false);
 }
Beispiel #29
0
        /// <summary>
        /// 获取排序字段
        /// </summary>
        public string GetOrderBy()
        {
            var exists = Properties.Any(t => t.PropertyName == "CreationTime" && t.SystemType == typeof(DateTime));

            if (exists)
            {
                return("CreationTime");
            }
            return("Id");
        }
Beispiel #30
0
Datei: It.cs Projekt: forki/Labs
        /// <summary>
        /// Does the actual transacted test
        /// </summary>
        /// <returns>Parent fluent object to start again if needed</returns>
        protected It RunTest()
        {
            Assert.IsNotNull(Target);
            Assert.IsNotNull(MethodName);
            Assert.IsFalse(string.IsNullOrEmpty(MethodName));
            Assert.IsNotNull(Properties);
            Assert.IsTrue(Properties.Any());

            return(AssertTransaction());
        }