コード例 #1
0
        private void CleanEntities(CleanType type)
        {
            List <Entity> newList = new List <Entity>();

            if (type == CleanType.Regular)
            {
                foreach (var entity in _entityDictionary.Values)
                {
                    if (entity.Alive)
                    {
                        newList.Add(entity);
                    }
                }
            }

            if (type == CleanType.Hero)
            {
                foreach (var entity in _entityDictionary.Values)
                {
                    if (entity.Type == EntityType.Hero)
                    {
                        newList.Add(entity);
                    }
                }
            }
            _entityDictionary.Clear();
            AddEntityList(newList);
        }
コード例 #2
0
ファイル: valueConvert.cs プロジェクト: icprog/PC
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value == null || value.Equals(0))
            {
                return(Visibility.Hidden);
            }
            if (int.Parse(value.ToString()) == 0)
            {
                return(Visibility.Hidden);
            }
            CleanType  tmp = (CleanType)UInt16.Parse(value.ToString());
            Visibility ret = Visibility.Hidden;

            switch (tmp)
            {
            case CleanType.CLEAN_DAILY:
                ret = parameter.ToString().Equals("CLEAN_DAILY") ? Visibility.Visible : Visibility.Hidden;
                break;

            case CleanType.CLEAN_WEEKLY:
                ret = parameter.ToString().Equals("CLEAN_WEEKLY") ? Visibility.Visible : Visibility.Hidden;
                break;

            case CleanType.CLEAN_WATERFLUSH:
                ret = parameter.ToString().Equals("CLEAN_WATERFLUSH") ? Visibility.Visible : Visibility.Hidden;
                break;

            case CleanType.CLEAN_FLUSH_BREW:
                ret = parameter.ToString().Equals("CLEAN_FLUSH_BREW") ? Visibility.Visible : Visibility.Hidden;
                break;

            case CleanType.CLEAN_CLEAN_BREW:
                ret = parameter.ToString().Equals("CLEAN_CLEAN_BREW") ? Visibility.Visible : Visibility.Hidden;
                break;

            case CleanType.CLEAN_CLEAN_MIXER:
                ret = parameter.ToString().Equals("CLEAN_CLEAN_MIXER") ? Visibility.Visible : Visibility.Hidden;
                break;

            case CleanType.CLEAN_CLEAN_VALVE:
                ret = parameter.ToString().Equals("CLEAN_CLEAN_VALVE") ? Visibility.Visible : Visibility.Hidden;

                break;

            case CleanType.CLEAN_CLEAN_GRINDER:
                ret = parameter.ToString().Equals("CLEAN_CLEAN_GRINDER") ? Visibility.Visible : Visibility.Hidden;

                break;

            case CleanType.CLEAN_OPEN_BREW:
                ret = parameter.ToString().Equals("CLEAN_OPEN_BREW") ? Visibility.Visible : Visibility.Hidden;

                break;

            default:
                break;
            }
            return(ret);
        }
コード例 #3
0
ファイル: EntityBase.cs プロジェクト: jeason0813/framework-2
        public Type SelectType(Func <Type, bool> filterType)
        {
            if (CleanType.IsEmbeddedEntity())
            {
                return(CleanType);
            }

            if (Implementations.Value.IsByAll)
            {
                throw new InvalidOperationException("ImplementedByAll is not supported for this operation, override the event");
            }

            return(Navigator.SelectType(Window.GetWindow(this), Implementations.Value.Types, filterType));
        }
コード例 #4
0
        public async Task Clean(MemoryStream data, CleanType clean, string relUrl)
        {
            var postData = $"src={HttpUtility.UrlEncode(data.ToArray())}" +
                           $"&clean={HttpUtility.UrlEncode(((int)clean).ToString())}";

            try
            {
                await Save(await Post(BeautifierURL, postData), relUrl).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                Console.WriteLine(
                    $"Unable to clean {relUrl} (maybe the service is down) \n\t{ex.Message} - {ex.StackTrace}");

                await Save(data, relUrl).ConfigureAwait(false);
            }
        }
コード例 #5
0
ファイル: EntityBase.cs プロジェクト: jeason0813/framework-2
        private object _OnViewing(object entity, bool creating)
        {
            if (Viewing != null)
            {
                return(Viewing(entity));
            }

            var options = new ViewOptions
            {
                PropertyRoute = CleanType.IsEmbeddedEntity() ? GetEntityPropertyRoute() : null,
            };

            bool isReadOnly = (ReadonlyEntity ?? Common.GetIsReadOnly(this)) && !creating;

            if (isReadOnly)
            {
                options.ReadOnly = isReadOnly;
            }

            return(Navigator.ViewUntyped(entity, options));
        }
コード例 #6
0
        public void CleanPoints(CleanType type, params IBackupCleanStrategy[] algorithms)
        {
            var pointsDel = algorithms.Select(temp => temp.Execute()).ToList();

            pointsDel.Sort();
            switch (type)
            {
            case CleanType.Max:
            {
                this.DeletePoints(pointsDel.Last());
                break;
            }

            case CleanType.Min:
            {
                this.DeletePoints(pointsDel.First());
                break;
            }

            default:
                throw new Exception("Wrong type.");
            }
        }
コード例 #7
0
 public static Mesh Clean(CleanType cleanType, Mesh mesh, GraphicsStream adjacency, GraphicsStream adjacencyOut)
 {
     throw new NotImplementedException();
 }
コード例 #8
0
 public static Mesh Clean(CleanType cleanType, Mesh mesh, int[] adjacency, out int[] adjacencyOut)
 {
     throw new NotImplementedException();
 }
コード例 #9
0
ファイル: EntityBase.cs プロジェクト: jeason0813/framework-2
        public override void OnLoad(object sender, RoutedEventArgs e)
        {
            base.OnLoad(sender, e);

            if (DesignerProperties.GetIsInDesignMode(this))
            {
                return;
            }

            if (this.NotSet(EntityBase.EntityTemplateProperty) && this.NotSet(EntityBase.EntityTemplateSelectorProperty))
            {
                var type = Type;

                if (this is EntityCombo && !type.IsLite()) //Allways going to be lite
                {
                    type = Lite.Generate(type);
                }

                EntityTemplate = Navigator.FindDataTemplate(this, type);
            }

            if (this.NotSet(EntityBase.ImplementationsProperty) && CleanType.IsEntity() && !CleanType.IsAbstract)
            {
                Implementations = Signum.Entities.Implementations.By(CleanType);
            }

            if (this.NotSet(EntityBase.CreateProperty) && Create)
            {
                Create =
                    CleanType.IsEmbeddedEntity() ? Navigator.IsCreable(CleanType) :
                    Implementations.Value.IsByAll ? false:
                    Implementations.Value.Types.Any(t => Navigator.IsCreable(t, isSearch: false));
            }

            if (this.NotSet(EntityBase.ViewProperty) && View)
            {
                View = CleanType.IsEmbeddedEntity() ? Navigator.IsViewable(CleanType) :
                       Implementations.Value.IsByAll ? true :
                       Implementations.Value.Types.Any(t => Navigator.IsViewable(t));
            }

            if (this.NotSet(EntityBase.NavigateProperty) && Navigate)
            {
                Navigate = CleanType.IsEmbeddedEntity() ? Navigator.IsNavigable(CleanType, isSearch: false) :
                           Implementations.Value.IsByAll ? true :
                           Implementations.Value.Types.Any(t => Navigator.IsNavigable(t, isSearch: false));
            }

            if (this.NotSet(EntityBase.FindProperty) && Find)
            {
                Find = CleanType.IsEmbeddedEntity() ? false:
                       Implementations.Value.IsByAll ? false :
                       Implementations.Value.Types.Any(t => Finder.IsFindable(t));
            }

            if (this.NotSet(EntityBase.ViewOnCreateProperty) && ViewOnCreate && !View)
            {
                ViewOnCreate = false;
            }

            UpdateVisibility();
        }
コード例 #10
0
 private static string GenPostData(MemoryStream stream, CleanType cleanType)
 => $"src={HttpUtility.UrlEncode(stream.ToArray())}"
 + $"&clean={HttpUtility.UrlEncode(((int)cleanType).ToString())}";
コード例 #11
0
 public BeautifierService(string beautifierUrl, IFileSaveService save, CleanType cleanType)
 {
     _save         = save;
     BeautifierUrl = beautifierUrl;
     CleanType     = cleanType;
 }
コード例 #12
0
 public FolderCleaner(DirectoryPath dir, CleanType clean)
 {
     _startTime = DateTime.Now;
     _dir       = dir;
     _clean     = clean;
 }
コード例 #13
0
 public FolderCleaner(string dir, CleanType clean)
 {
     _startTime = DateTime.Now;
     _clean     = clean;
     _dir       = new DirectoryPath(dir);
 }
コード例 #14
0
 public static Mesh Clean(CleanType cleanType, Mesh mesh, GraphicsStream adjacency, GraphicsStream adjacencyOut, out string errorsAndWarnings)
 {
     throw new NotImplementedException();
 }
コード例 #15
0
        public MappedType ToMappedType()
        {
            var match      = CompilerGeneratedRegex.Match(CleanType.Name);
            var mappedType = new MappedType(ObfuscatedType.FullName, match.Success ? (match.Groups[1].Value + "__d") : CleanType.Name.Replace("<>", ""));

            if (ObfuscatedType.Fields.Count == CleanType.Fields.Count)
            {
                for (var i = 0; i < CleanType.Fields.Count; i++)
                {
                    var cleanField      = CleanType.Fields[i];
                    var obfuscatedField = ObfuscatedType.Fields[i];

                    if (ObfuscatedType.DeclaringType != null)
                    {
                        switch (obfuscatedField.Name)
                        {
                        case "<>1__state":
                            mappedType.Fields.Add(new MappedMember(obfuscatedField.Name, "__state"));
                            continue;

                        case "<>2__current":
                            mappedType.Fields.Add(new MappedMember(obfuscatedField.Name, "__current"));
                            continue;

                        case "<>4__this":
                            mappedType.Fields.Add(new MappedMember(obfuscatedField.Name, "__this"));
                            continue;
                        }

                        var fieldMatch = CompilerGeneratedRegex.Match(obfuscatedField.Name);

                        if (fieldMatch.Success)
                        {
                            mappedType.Fields.Add(new MappedMember(obfuscatedField.Name, fieldMatch.Groups[1].Value));
                            continue;
                        }
                    }

                    if (!obfuscatedField.Name.IsObfuscated())
                    {
                        continue;
                    }

                    mappedType.Fields.Add(new MappedMember(obfuscatedField.Name, cleanField.Name));
                }
            }

            if (ObfuscatedType.Properties.Count == CleanType.Properties.Count)
            {
                for (var i = 0; i < CleanType.Properties.Count; i++)
                {
                    var cleanProperty      = CleanType.Properties[i];
                    var obfuscatedProperty = ObfuscatedType.Properties[i];

                    if (!obfuscatedProperty.Name.IsObfuscated())
                    {
                        continue;
                    }

                    mappedType.Properties.Add(new MappedMember(obfuscatedProperty.Name, cleanProperty.Name));
                }
            }

            foreach (var cleanMethod in CleanType.GetMethods())
            {
                if (ObfuscatedType.GetMethods().Any(x => x.Name == cleanMethod.Name))
                {
                    continue;
                }

                var matching = new List <MethodDefinition>();

                foreach (var obfuscatedMethod in ObfuscatedType.GetMethods().Where(x => x.Name.IsObfuscated()))
                {
                    if (cleanMethod.ReturnType.FullName != obfuscatedMethod.ReturnType.FullName)
                    {
                        continue;
                    }

                    if (cleanMethod.Attributes.IgnoreVisibility() != obfuscatedMethod.Attributes.IgnoreVisibility())
                    {
                        continue;
                    }

                    if (cleanMethod.Parameters.Count != obfuscatedMethod.Parameters.Count)
                    {
                        continue;
                    }

                    var validParameters = true;

                    for (var i = 0; i < cleanMethod.Parameters.Count; i++)
                    {
                        var cleanParameter      = cleanMethod.Parameters[i];
                        var obfuscatedParameter = obfuscatedMethod.Parameters[i];

                        var obfuscatedParameterContext = Context.Map.SingleOrDefault(x => x.Key.FullName == obfuscatedParameter.ParameterType.FullName).Value;

                        if (cleanParameter.ParameterType.FullName != (obfuscatedParameterContext == null ? obfuscatedParameter.ParameterType.FullName : obfuscatedParameterContext.CleanFullName))
                        {
                            validParameters = false;
                            break;
                        }
                    }

                    if (!validParameters)
                    {
                        continue;
                    }

                    matching.Add(obfuscatedMethod);

                    if (matching.Count > 1)
                    {
                        break;
                    }
                }

                if (matching.Count == 1)
                {
                    var matched = matching.Single();

                    mappedType.Methods.Add(new MappedMethod(matched, cleanMethod.Name));
                }
            }

            if (ObfuscatedType.DeclaringType != null)
            {
                foreach (var obfuscatedMethod in ObfuscatedType.Methods)
                {
                    var methodMatch = CompilerGeneratedRegex.Match(obfuscatedMethod.Name);

                    if (methodMatch.Success)
                    {
                        mappedType.Methods.Add(new MappedMethod(obfuscatedMethod, methodMatch.Groups[1].Value));
                    }
                }
            }

            foreach (var nestedTypeContext in Nested)
            {
                var nestedType = nestedTypeContext.ToMappedType();
                if (nestedType != null)
                {
                    mappedType.Nested.Add(nestedType);
                }
            }

            if (!ObfuscatedType.Name.IsObfuscated() && !mappedType.Fields.Any() && !mappedType.Methods.Any() && !mappedType.Properties.Any() && !mappedType.Nested.Any())
            {
                return(null);
            }

            return(mappedType);
        }
コード例 #16
0
        public MappedType ToMappedType()
        {
            var mappedType = new MappedType(ObfuscatedType.FullName, CleanType.Name.Clean());

            if (!string.IsNullOrEmpty(CleanType.Namespace))
            {
                mappedType.Mapped = CleanType.Namespace + "." + mappedType.Mapped;
            }

            if (ObfuscatedType.FullName == CleanFullName)
            {
                mappedType.Mapped = null;
            }

            if (ObfuscatedType.Fields.Count == CleanType.Fields.Count)
            {
                var sortedCleanFields = CleanType.Fields.OrderBy(x => x.HasConstant && x.Constant is string).ToArray();

                for (var i = 0; i < CleanType.Fields.Count; i++)
                {
                    var cleanField      = sortedCleanFields[i];
                    var obfuscatedField = ObfuscatedType.Fields[i];

                    if (ObfuscatedType.DeclaringType != null)
                    {
                        var clean = obfuscatedField.Name.Clean();

                        if (clean != obfuscatedField.Name)
                        {
                            mappedType.Fields.Add(new MappedMember(obfuscatedField.Name, clean));
                            continue;
                        }
                    }

                    if (!obfuscatedField.Name.IsObfuscated())
                    {
                        continue;
                    }

                    mappedType.Fields.Add(new MappedMember(obfuscatedField.Name, cleanField.Name));
                }
            }

            if (ObfuscatedType.Properties.Count == CleanType.Properties.Count)
            {
                for (var i = 0; i < CleanType.Properties.Count; i++)
                {
                    var cleanProperty      = CleanType.Properties[i];
                    var obfuscatedProperty = ObfuscatedType.Properties[i];

                    if (!obfuscatedProperty.Name.IsObfuscated())
                    {
                        continue;
                    }

                    mappedType.Properties.Add(new MappedMember(obfuscatedProperty.Name, cleanProperty.Name));
                }
            }

            foreach (var cleanMethod in CleanType.GetMethods())
            {
                if (ObfuscatedType.GetMethods().Any(x => x.Name == cleanMethod.Name))
                {
                    continue;
                }

                var matching = new List <MethodDefinition>();

                foreach (var obfuscatedMethod in ObfuscatedType.GetMethods().Where(x => x.Name.IsObfuscated()))
                {
                    if (cleanMethod.ReturnType.FullName != obfuscatedMethod.ReturnType.FullName)
                    {
                        continue;
                    }

                    if (cleanMethod.Attributes.IgnoreVisibility() != obfuscatedMethod.Attributes.IgnoreVisibility())
                    {
                        continue;
                    }

                    if (cleanMethod.Parameters.Count != obfuscatedMethod.Parameters.Count)
                    {
                        continue;
                    }

                    var validParameters = true;

                    for (var i = 0; i < cleanMethod.Parameters.Count; i++)
                    {
                        var cleanParameter      = cleanMethod.Parameters[i];
                        var obfuscatedParameter = obfuscatedMethod.Parameters[i];

                        var obfuscatedParameterContext = Context.Map.SingleOrDefault(x => x.Key.FullName == obfuscatedParameter.ParameterType.FullName).Value;

                        if (cleanParameter.ParameterType.FullName != (obfuscatedParameterContext == null ? obfuscatedParameter.ParameterType.FullName : obfuscatedParameterContext.CleanFullName))
                        {
                            validParameters = false;
                            break;
                        }
                    }

                    if (!validParameters)
                    {
                        continue;
                    }

                    matching.Add(obfuscatedMethod);

                    if (matching.Count > 1)
                    {
                        break;
                    }
                }

                if (matching.Count == 1)
                {
                    var matched = matching.Single();

                    mappedType.Methods.Add(new MappedMethod(matched, cleanMethod.Name));
                }
            }

            if (ObfuscatedType.DeclaringType != null)
            {
                foreach (var obfuscatedMethod in ObfuscatedType.Methods)
                {
                    var clean = obfuscatedMethod.Name.Clean();

                    if (clean != obfuscatedMethod.Name)
                    {
                        mappedType.Methods.Add(new MappedMethod(obfuscatedMethod, clean));
                    }
                }
            }

            foreach (var nestedTypeContext in Nested)
            {
                var nestedType = nestedTypeContext.ToMappedType();
                if (nestedType != null)
                {
                    mappedType.Nested.Add(nestedType);
                }
            }

            if (!ObfuscatedType.Name.IsObfuscated() && !mappedType.Fields.Any() && !mappedType.Methods.Any() && !mappedType.Properties.Any() && !mappedType.Nested.Any())
            {
                return(null);
            }

            return(mappedType);
        }
コード例 #17
0
ファイル: ModerationModule.cs プロジェクト: cryy/quiccban
 public Task <CommandResult> CleanAsync(CleanType type, int quota = 100, SocketGuildUser u = null)
 => CleanAsync(u == null ? 0 : u.Id, quota, new CleanType[] { type });