コード例 #1
0
    public override void ExecuteBuild()
    {
        var bLayered        = ParseParam("layered");
        var SourceDirectory = ParseParamValue("sourcedirectory", null);
        var TargetDirectory = ParseParamValue("targetdirectory", null);
        var CryptoKeysFile  = ParseParamValue("cryptokeysjson", null);
        var Compressor      = ParseParamValue("customcompressor", null);
        var Project         = ParseParamValue("project", null);

        string ExtraArgs = "";

        if (!string.IsNullOrEmpty(Compressor))
        {
            ExtraArgs += "-customcompressor=" + Compressor;
        }

        if (Params.Contains("passargs"))
        {
            IEnumerable <string> ExtraArgArray = Params.Where((arg, index) => index > Array.IndexOf(Params, "passargs"));

            if (ExtraArgArray.Count() > 0)
            {
                ExtraArgs += " -" + string.Join(" -", ExtraArgArray);
            }
        }

        if (String.IsNullOrEmpty(SourceDirectory))
        {
            throw new AutomationException("SourceDirectory is a required parameter");
        }
        if (String.IsNullOrEmpty(TargetDirectory))
        {
            throw new AutomationException("TargetDirectory is a required parameter");
        }
        if (String.IsNullOrEmpty(CryptoKeysFile))
        {
            throw new AutomationException("CryptoKeysJson is a required parameter");
        }

        DirectoryInfo SourceDirectoryInfo = new DirectoryInfo(SourceDirectory);

        LogInformation("Extracting paks from {0} to {1}", SourceDirectory, TargetDirectory);

        FileReference ProjectFile = null;

        if (!string.IsNullOrEmpty(Project))
        {
            ProjectFile = ProjectUtils.FindProjectFileFromName(Project);

            if (ProjectFile == null)
            {
                throw new AutomationException("Could not find project file based on {0}", Project);
            }
        }

        PackageUtils.ExtractPakFiles(SourceDirectoryInfo, TargetDirectory, CryptoKeysFile, ExtraArgs, bLayered, ProjectFile);
    }
コード例 #2
0
        /// <summary>
        /// 运行自定义命令。
        /// </summary>
        /// <exception cref="OperationCanceledException"/>
        public void SaveData(string des)
        {
            Process process = string.IsNullOrWhiteSpace(Params) ?
                              Process.Start(Command) :
                              Process.Start(Command, Params.Contains("{0}") ? string.Format(Params, des) : Params);

#if DEBUG
            process.OutputDataReceived += (sender, e) => Log.Info(e.Data);
            process.BeginOutputReadLine();
#endif
            process.WaitForExit();
            if (process.ExitCode == 0)
            {
                throw new OperationCanceledException(string.Format("自定义命令返回了错误码 {0}。", process.ExitCode));
            }
        }
コード例 #3
0
        public void LoadParameters(string filename, Context[] ctx = null, bool allow_missing = false,
                                   bool ignore_extra = false, bool cast_dtype = false, string dtype_source = "current")
        {
            var loaded           = new NDArrayDict();
            var collected_params = CollectParamsWithPrefix();

            NDArray.Load(filename, out loaded);

            if (loaded == null && collected_params == null)
            {
                return;
            }

            if (!loaded.Keys.Any(x => x.Contains(".")))
            {
                loaded = null;
                CollectParams().Load(filename, ctx, allow_missing, ignore_extra, Prefix, cast_dtype, dtype_source);
                return;
            }

            if (!allow_missing)
            {
                foreach (var name in Params.Keys())
                {
                    if (!loaded.Contains(name))
                    {
                        throw new Exception(string.Format("Parameter '{0}' is missing in file '{1}'", name, filename));
                    }
                }
            }

            foreach (var name in loaded.Keys)
            {
                if (!ignore_extra && !Params.Contains(name))
                {
                    throw new Exception(string.Format(
                                            "Parameter '{0}' loaded from file {1} is not present in ParameterDict", name, filename));
                }

                if (Params.Contains(name))
                {
                    Params[name].LoadInit(loaded[name], ctx, cast_dtype, dtype_source);
                }
            }
        }
コード例 #4
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            litTopicPropButton.Text = "<div><a href=\"\" onclick=\"afadmin_LoadPropForm();return false;\" class=\"btnadd afroundall\">[RESX:AddProperty]</a></div>";
            litPropLoad.Text        = Utilities.GetFileResource("DotNetNuke.Modules.ActiveForums.scripts.afadmin.properties.js");

            BindRoles();

            var sepChar = '|';

            if (Params != null && !(string.IsNullOrEmpty(Params)))
            {
                if (Params.Contains("!"))
                {
                    sepChar = '!';
                }

                editorType = Params.Split(sepChar)[1]; // Params.Split(CChar(sepChar))(1).Split(CChar("="))(1)
                recordId   = Utilities.SafeConvertInt(Params.Split(sepChar)[0]);
            }

            if (editorType == "G")
            {
                trGroups.Visible           = false;
                reqGroups.Enabled          = false;
                trDesc.Visible             = false;
                trInherit.Visible          = false;
                lblForumGroupName.Text     = GetSharedResource("[RESX:GroupName]");
                btnDelete.ClientSideScript = "deleteGroup();";
            }
            else
            {
                lblForumGroupName.Text = GetSharedResource("[RESX:ForumName]");
                trInherit.Visible      = true;
                chkInheritGroup.Attributes.Add("onclick", "amaf_toggleInherit();");
                btnDelete.ClientSideScript = "deleteForum();";
            }

            if (recordId == 0)
            {
                btnDelete.Visible = false;
            }

            imgOn             = Page.ResolveUrl("~/DesktopModules/ActiveForums/images/admin_check.png");
            imgOff            = Page.ResolveUrl("~/DesktopModules/ActiveForums/images/admin_stop.png");
            reqForumName.Text = "<img src=\"" + Page.ResolveUrl(RequiredImage) + "\" />";
            reqGroups.Text    = "<img src=\"" + Page.ResolveUrl(RequiredImage) + "\" />";
            var propImage = "<img src=\"" + Page.ResolveUrl("~/DesktopModules/ActiveForums/images/properties16.png") + "\" alt=\"[RESX:ConfigureProperties]\" />";

            rdAttachOn.Attributes.Add("onclick", "toggleAttach(this);");
            rdAttachOn.Attributes.Add("value", "1");
            rdAttachOff.Attributes.Add("onclick", "toggleAttach(this);");
            rdAttachOff.Attributes.Add("value", "0");
            cfgAttach.InnerHtml = propImage;

            rdHTMLOn.Attributes.Add("onclick", "toggleEditor(this);");
            rdHTMLOff.Attributes.Add("onclick", "toggleEditor(this);");
            rdHTMLOn.Attributes.Add("value", "1");
            rdHTMLOff.Attributes.Add("value", "0");
            cfgHTML.Attributes.Add("style", "display:none;");
            cfgHTML.InnerHtml = propImage;
            rdModOn.Attributes.Add("onclick", "toggleMod(this);");
            rdModOff.Attributes.Add("onclick", "toggleMod(this);");
            rdModOn.Attributes.Add("value", "1");
            rdModOff.Attributes.Add("value", "0");
            cfgMod.Attributes.Add("style", "display:none;");
            cfgMod.InnerHtml = propImage;

            trAutoSub.Visible = true;
            rdAutoSubOn.Attributes.Add("onclick", "toggleAutoSub(this);");
            rdAutoSubOff.Attributes.Add("onclick", "toggleAutoSub(this);");
            rdAutoSubOn.Attributes.Add("value", "1");
            rdAutoSubOff.Attributes.Add("value", "0");
            cfgAutoSub.Attributes.Add("style", "display:none;");
            cfgAutoSub.InnerHtml = propImage;
            txtOlderThan.Attributes.Add("onkeypress", "return onlyNumbers(event)");
            txtReplyOlderThan.Attributes.Add("onkeypress", "return onlyNumbers(event)");
            txtUserId.Attributes.Add("onkeypress", "return onlyNumbers(event)");

            if (MainSettings.DeleteBehavior == 1)
            {
                lblMaintWarn.Text = string.Format(GetSharedResource("[RESX:MaintenanceWarning]"), GetSharedResource("[RESX:MaintenanceWarning:Recycle]"), GetSharedResource("[RESX:MaintenanceWarning:Recycle:Desc]"));
            }
            else
            {
                lblMaintWarn.Text = string.Format(GetSharedResource("[RESX:MaintenanceWarning]"), GetSharedResource("[RESX:MaintenanceWarning:Remove]"), GetSharedResource("[RESX:MaintenanceWarning:Remove:Desc]"));
            }

            drpEditorTypes.Attributes.Add("onchange", "toggleEditorFields();");

            if (cbEditorAction.IsCallback)
            {
                return;
            }

            BindGroups();
            BindTemplates();

            if (recordId > 0)
            {
                switch (editorType)
                {
                case "F":
                    LoadForum(recordId);
                    break;

                case "G":
                    LoadGroup(recordId);
                    break;
                }

                cfgHTML.Attributes.Add("onclick", "showProp(this,'edProp')");

                cfgMod.Attributes.Add("onclick", "showProp(this,'modProp')");

                cfgAutoSub.Attributes.Add("onclick", "showProp(this,'subProp')");

                cfgAttach.Attributes.Add("onclick", "showProp(this,'attachProp')");

                var sb = new StringBuilder();
                sb.Append("<script type=\"text/javascript\">");
                sb.Append("function toggleAutoSub(obj){");
                sb.Append("    closeAllProp();");
                sb.Append("    var mod = document.getElementById('" + cfgAutoSub.ClientID + "');");
                sb.Append("    if (obj.value == '1'){");
                sb.Append("        mod.style.display = '';");
                sb.Append("    }else{");
                sb.Append("        mod.style.display = 'none';");
                sb.Append("        var winDiv = document.getElementById('subProp');");
                sb.Append("        mod.style.display = 'none';");
                sb.Append("    };");
                sb.Append("};");

                sb.Append("</script>");
                litScripts.Text = sb.ToString();
            }

            BindTabs();
        }
コード例 #5
0
ファイル: SRBuff.cs プロジェクト: simsekahmett/xBot-WinForms
 public bool hasAutoTransferEffect()
 {
     return(Params.Contains("|" + (uint)Game.Params.Effect.AUTO_TRANSFER));
 }
コード例 #6
0
 public bool Contains(ParamInfo param)
 {
     return(Params.Contains(param));
 }
コード例 #7
0
 public bool ContainsParam(Symbol s)
 {
     return(Params.Contains(s));
 }
コード例 #8
0
        private static void Main(string[] args)
        {
            //Console.WriteLine(Resources.EditorGUI);

            Regex           ItemRegex = new Regex(@"public static(?<MethodName>.+?)\((?<Params>.+?)\)(?<=([^;]))+$", RegexOptions.Multiline | RegexOptions.Compiled);
            MatchCollection matches   = ItemRegex.Matches(Resources.EditorGUI);

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("using System;");
            sb.AppendLine("using System.Collections.Generic;");
            sb.AppendLine("using System.Linq;");
            sb.AppendLine("using UnityEngine;");
            sb.AppendLine("using UnityEngine.Internal;");
            sb.AppendLine("using UnityEngine.Rendering;");
            sb.AppendLine("using UnityEditor;");
            sb.AppendLine("using Object = UnityEngine.Object;");
            sb.AppendLine();

            sb.AppendLine("namespace z3nth10n.EditorUtils");
            sb.AppendLine("{");

            sb.AppendLineIndented(@"
                                    public static class FEditor
                                    {
                                        public static void AddOrSet<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, TKey key, TValue value)
                                        {
                                            if (!dictionary.ContainsKey(key))
                                                dictionary.Add(key, value);
                                            else
                                                dictionary[key] = value;
                                        }
                                    }", 1);

            sb.AppendLine();

            sb.AppendLineIndented(@"
                                    public sealed class StyleWrapper
                                    {
                                        public Dictionary<GUIStyle, GUIContents> listWrapper = new Dictionary<GUIStyle, GUIContents>();

                                        public StyleWrapper(GUIStyle style, GUIContent label)
                                        {
                                            listWrapper.AddOrSet(style, GUIContents.AddOrSet(GUIContents.GetContents(style.name), label));
                                        }

                                        public StyleWrapper(GUIStyle style, string label)
                                        {
                                            listWrapper.AddOrSet(style, GUIContents.AddOrSet(GUIContents.GetContents(style.name), new GUIContent(label)));
                                        }
                                    }

                                    public sealed class GUIContents
                                    {
                                        private static Dictionary<string, GUIContents> dictionary = new Dictionary<string, GUIContents>();

                                        public List<GUIContent> list = new List<GUIContent>();

                                        public static GUIContents GetContents(string name)
                                        {
                                            if (!dictionary.ContainsKey(name))
                                                dictionary.Add(name, new GUIContents());

                                            return dictionary[name];
                                        }

                                        public static GUIContents AddOrSet(GUIContents contents, GUIContent content)
                                        {
                                            int index = contents.list.IndexOf(content);

                                            if (index == -1)
                                                contents.list.Add(content);
                                            else
                                                contents.list[index] = content;

                                            return contents;
                                        }
                                    }", 1);

            sb.AppendLine();

            sb.AppendLineIndented("// I suggest you not to implement anything here due to generation. Use partial approach.", 1);
            sb.AppendLineIndented("public sealed partial class xEditorGUI", 1);
            sb.AppendLineIndented("{", 1);

            sb.AppendLineIndented("private Dictionary<string, StyleWrapper> stylesDict = new Dictionary<string, StyleWrapper>();", 2);
            sb.AppendLine();

            sb.AppendLineIndented("private Rect _position;", 2);
            sb.AppendLine();

            foreach (Match ItemMatch in matches)
            {
                string methodDef = ItemMatch.Value.Replace(" static", "");

                sb.AppendLineIndented($"{methodDef}", 2);
                sb.AppendLineIndented("{", 2);

                string[]   parsArr    = null;
                string[][] parsPreObj = null;

                string replacedGeneric = "";

                string[] methodWithType = ItemMatch.Groups["MethodName"].Value.Trim().Split(' ');

                try
                {
                    string Params = ItemMatch.Groups["Params"].Value;

                    bool hasOptionalParams           = Params.Contains('='),
                         hasAttributedParams         = Params.Contains(")]"),
                         hasOptionalAttributedParams = hasOptionalParams && hasAttributedParams;

                    if (hasOptionalAttributedParams)
                    {
                        sb.AppendLineIndented(@"throw new Exception(""Methods with optional attributed params aren't implemented yet!"");", 3);
                    }

                    bool isSupported = true;

                    // Console.WriteLine(methodWithType[1]);

                    if (!hasAttributedParams)
                    {
                        if (methodExceptions.Contains(methodWithType[1]))
                        {
                            if (!hasOptionalAttributedParams)
                            {
                                sb.AppendLineIndented(@"throw new Exception(""This method isn't supported!"");", 3);
                            }

                            isSupported = false;
                        }
                    }

                    if (Params.Contains('='))
                    {
                        Params = new Regex(" =.+?,").Replace(Params, ",");
                    }

                    if (Params.Contains('='))
                    {
                        Params = new Regex(" =.+?$").Replace(Params, "");
                    }

                    replacedGeneric = Params.ReplaceIf(", ", ",", '<');
                    parsArr         = replacedGeneric.Split(new string[] { ", " }, StringSplitOptions.None).ToArray();

                    parsPreObj = parsArr
                                 .Select(x => x.Trim().ReplaceIf("] ", "]", ")]").Split(' '))
                                 .ToArray();

                    IEnumerable <Param> parsObjects = parsPreObj.Select(x => x.Length == 2 ? new Param(x.First(), x[1]) : new Param(x[0], x[1], x[2]));

                    bool isEditorMethod = false;

                    if (parsObjects.Any(x => x.type == "Editor"))
                    {
                        if (isSupported && !hasOptionalAttributedParams)
                        {
                            sb.AppendLineIndented(@"throw new Exception(""Methods with Editor type in it's parameters aren't implemented yet!"");", 3);
                        }

                        isEditorMethod = true;
                    }

                    if (isSupported)
                    {
                        bool isLayout = !parsObjects.Any(x => x.type == "Rect" && x.name == "position");

                        IEnumerable <string> parsNames = parsObjects.Select(x => x.name);

                        string contentParam = parsNames.GetGUIContentParamName();

                        bool hasStyle = parsNames.Contains("style");

                        string pars = parsObjects.GetParams();

                        string styleName = methodWithType[1].FirstCharToLower();

                        bool styleExists = styleNames.Contains(styleName),
                        // addBody = hasStyle || styleExists,
                             hasNoContent = string.IsNullOrEmpty(contentParam);

                        if (hasNoContent)
                        {
                            contentParam = "GUIContent.none";
                        }

                        if (isLayout && !isEditorMethod && !hasOptionalAttributedParams && isSupported)
                        {
                            sb.AppendLineIndented(@"// throw new Exception(""No implementation Layout yet!"");", 3);
                        }

                        if (parsObjects.Any(x => x.name == "options"))
                        {
                            sb.AppendLineIndented(@"
                                                if (options != null)
                                                    throw new ArgumentException(""Options use isn't supported yet!"", ""options"");
                                    ", 3);
                        }

                        if (isEditorMethod || hasOptionalAttributedParams)
                        {
                            sb.AppendLineIndented("/*", 3);
                        }

                        sb.AppendLineIndented($@"if(!stylesDict.ContainsKey(""{methodWithType[1]}""))", 3);

                        string currentStyle = hasStyle ? "style" : styleExists ? $"EditorStyles.{styleName}" : $@"new GUIStyle(""{styleName}"")";

                        sb.AppendLineIndented($@"stylesDict.Add(""{methodWithType[1]}"", new StyleWrapper({currentStyle}, {contentParam}));", 4);
                        sb.AppendLine();

                        bool dontNeedPosition = methodsDontNeedPosition.Contains(methodWithType[1]); // (!isLayout || isLayout);

                        if (forcedLayoutMethods.Contains(methodWithType[1]) && !parsObjects.Any(x => x.type == "Rect"))
                        {
                            dontNeedPosition = false;
                        }

                        if (!dontNeedPosition)
                        {
                            sb.AppendLineIndented("Rect lastPosition = _position;", 3);
                            sb.AppendLineIndented($"UpdatePosition({currentStyle}, {contentParam});", 3);
                            sb.AppendLine();
                        }

                        string _unsupportedParams = "",
                               modifiedParams     = F.GetLayoutParams(pars, unsupportedParams, isLayout && !dontNeedPosition, out _unsupportedParams);

                        if (!string.IsNullOrEmpty(_unsupportedParams))
                        {
                            sb.AppendLineIndented($"// This call has the following ({_unsupportedParams.Count(x => x == ',') + 1}) unsupported params (an implementation is required): {_unsupportedParams}", 3);
                        }

                        // parsObjects.Any(x => x.type == "string[]") &&
                        if (parsObjects.Any(x => x.type.Contains("GUIContent")) && typesMismatch.Contains(methodWithType[1]))
                        {
                            Param param = parsObjects.First(x => x.type == "string[]");

                            modifiedParams = modifiedParams.Replace(param.name, param.name + ".Select(x => new GUIContent(x)).ToArray()");
                        }

                        if (convertedNeeded.Contains(methodWithType[1]) && parsObjects.First(x => x.name == "label").type == "string")
                        {
                            modifiedParams = new Regex(@"\blabel\b").Replace(modifiedParams, "(Converters)label");
                        }

                        if (methodWithType[1] == "HelpBox" && !parsObjects.Any(x => x.type == "MessageType"))
                        {
                            modifiedParams  = modifiedParams.Replace("content", "content.text");
                            modifiedParams += ", default(MessageType)";
                        }

                        sb.AppendLineIndented($"{(methodWithType[0] == "void" ? "" : "return ")}EditorGUI.{methodWithType[1]}({modifiedParams});", 3);

                        if (isEditorMethod || hasOptionalAttributedParams)
                        {
                            sb.AppendLineIndented("*/", 3);
                        }
                    }
                }
                catch (Exception ex)
                {
                    sb.AppendLineIndented($"// Couldn't add this line! (Exception: {ex.GetType().FullName} -- At line: {ex.LineNumber()})", 3);

                    if (methodWithType[0] != "void")
                    {
                        sb.AppendLineIndented("throw new Exception();", 3);
                    }
                }

                sb.AppendLineIndented("}", 2);
                sb.AppendLine();
            }

            sb.AppendLineIndented(@"
                                    public float GetHeight()
                                    {
                                        float size = 0;

                                        foreach (StyleWrapper wrapper in stylesDict.Values)
                                            size += wrapper.listWrapper.Sum(x => x.Value.list.Sum(y => x.Key.CalcSize(y).y));

                                        return size;
                                    }

                                    private void UpdatePosition(GUIStyle style, string label)
                                    {
                                        UpdatePosition(style, new GUIContent(label));
                                    }

                                    /*private void UpdatePosition(GUIStyle style, GUIContent content)
                                    {
                                        Vector2 vector = style.CalcSize(content);

                                        float width = 0, height = 0;

                                        style.CalcMinMaxWidth(content, out width, out height);

                                        _position.yMin += vector.y;
                                        _position.xMin = vector.y;
                                        _position.width = width;
                                        _position.height = height;
                                    }*/", 2);

            sb.AppendLineIndented("}", 1);

            sb.AppendLineIndented(@"
                                    public class Converters : GUIContent
                                    {
                                        public static implicit operator Converters(string str)
                                        {
                                            return (Converters)new GUIContent(str);
                                        }
                                    }", 1);

            sb.AppendLine("}");

            string codeGen = sb.ToString();

            codeGen.CopyToClipboard();

            Console.WriteLine($"{codeGen.Length} characters copied to clipboard.");

            Console.Read();
        }