コード例 #1
0
        public SecurityAccount GetAccount(IdentityReference ident)
        {
            SecurityAccount ret = null;

            lock (_lock)
            {
                if (accountCache.TryGetValue(ident.Value, out ret))
                {
                    Utils.Free(ident);
                    return(ret);
                }
            }

            SecurityAccount created = factory(this, ident);

            lock (_lock)
            {
                if (accountCache.TryGetValue(ident.Value, out ret))
                {
                    Utils.Free(ident);
                    Utils.Free(created);
                    return(ret);
                }
                accountList = null;
                accountCache.Add(created.NTAccount.Value, created);
                accountCache.Add(created.Sid.Value, created);
            }
            return(created);
        }
コード例 #2
0
ファイル: XMLRPC.cs プロジェクト: nerochiaro/webcontent-cs
        public object Retrieve(string serviceName, XmlRpcStruct args)
        {
            Console.WriteLine("Service \"{0}\"", serviceName);
            ProvidersManager providers = new ProvidersManager();
            Extractable service = null;
            try {
                service = providers.FindService(serviceName);
            }
            catch (InvalidNameException) {
                string msg = "The name of the service should be in the format NameSpace.ServiceName";
                throw new XmlRpcFaultException(32602, msg);
            }
            catch (ServiceNotFoundException) {
                string msg = String.Format("The service \"{0}\" does not exist on this server.", serviceName);
                throw new XmlRpcFaultException(32602, msg);
            }

            Console.WriteLine("Arguments (as strings):");
            StringDict arguments = new StringDict();
            foreach (DictionaryEntry keyval in args) {
                arguments.Add((string)keyval.Key, keyval.Value.ToString());
                Console.WriteLine("{0}=>{1}", keyval.Key, keyval.Value);
            }

            service.Extract(arguments);

            Console.WriteLine("Result: {0}", service.ToString());
            return service;
        }
コード例 #3
0
        public PrincipalContext GetPricipalContext(String name, params ContextType[] ctx)
        {
            if (name == null)
            {
                return(null);
            }

            PrincipalContext ret = null;

            lock (_lock)
            {
                if (contextCache.TryGetValue(name, out ret))
                {
                    return(ret);
                }
            }

            PrincipalContext created = createPricipalContext(name, ContextType.Machine, ContextType.Domain, ContextType.ApplicationDirectory);

            lock (_lock)
            {
                if (contextCache.TryGetValue(name, out ret))
                {
                    Utils.FreeAndNil(ref created);
                    return(ret);
                }
                contextCache.Add(name, created);
                return(created);
            }
        }
コード例 #4
0
ファイル: Variables.cs プロジェクト: lanicon/ImportPipeline
 protected virtual void copyFrom(Variables other)
 {
     foreach (var kvp in other)
     {
         vars.Add(kvp.Key, kvp.Value);
     }
 }
コード例 #5
0
 public NamedAdminCollection(XmlNode collNode, String childrenNode, Func <XmlNode, T> factory, bool mandatory)
     : base(collNode, childrenNode, factory, mandatory)
 {
     namedItems = new StringDict <T>(Count);
     for (int i = 0; i < Count; i++)
     {
         T item = base[i];
         namedItems.Add(item.Name, item);
     }
 }
コード例 #6
0
        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                AppDomain.CurrentDomain.AssemblyResolve += onResolve;
                AppDomain.CurrentDomain.AssemblyLoad    += onLoad;
                trySetIcon();
                String dir = Assembly.GetExecutingAssembly().Location;

                StringDict dirs = new StringDict();
                dir = IOUtils.FindDirectoryToRoot(Path.GetDirectoryName(dir), "ImportDirs");
                if (dir != null)
                {
                    dirs.Add(dir, null);
                }

                StringDict files = new StringDict();
                foreach (var f in History.LoadHistory(HISTORY_KEY))
                {
                    files[f] = null;
                    dir      = Path.GetDirectoryName(Path.GetDirectoryName(f));
                    if (!String.IsNullOrEmpty(dir))
                    {
                        dirs[dir] = null;
                    }
                }

                foreach (var kvp in dirs)
                {
                    FileTree tree = new FileTree();
                    tree.AddFileFilter(@"\\import\.xml$", true);
                    tree.ReadFiles(kvp.Key);
                    if (tree.Files.Count != 0)
                    {
                        tree.Files.Sort();
                        foreach (var relfile in tree.Files)
                        {
                            files[tree.GetFullName(relfile)] = null;
                        }
                    }
                }

                ac = new DirectoryAutocompleter(comboBox1, files.Select(kvp => kvp.Key).ToList());
                if (comboBox1.Items.Count > 0)
                {
                    comboBox1.SelectedIndex = 0;
                }
            }
            catch (Exception ex)
            {
                Logs.ErrorLog.Log(ex);
                throw;
            }
        }
コード例 #7
0
        public ESIndexDefinitions(XmlHelper xml, XmlNode node, OnLoadConfig onLoadConfig = null)
        {
            XmlNodeList nodes = node.SelectMandatoryNodes("index");

            list = new List <ESIndexDefinition>(nodes.Count);
            dict = new StringDict <ESIndexDefinition>(nodes.Count);

            foreach (XmlNode x in nodes)
            {
                ESIndexDefinition def = new ESIndexDefinition(xml, x, onLoadConfig);
                list.Add(def);
                dict.Add(def.Name, def);
            }
        }
コード例 #8
0
        public static void LoadDictionary(StringDict dict, string dictPath, bool ignoreComment = false)
        {
            using var textReader = new StreamReader(dictPath, true);

            foreach (var line in textReader.Lines())
            {
                if (ignoreComment == true && line.StartsWith("#"))
                {
                    continue;
                }
                var tuple = line.Split('=');
                if (tuple.Length == 2 && !dict.ContainsKey(tuple[0]))
                {
                    dict.Add(tuple[0], tuple[1]);
                }
            }
        }
コード例 #9
0
        public PostProcessors(ImportEngine engine, XmlNode collNode)
        {
            postProcessors = new StringDict <IPostProcessor>();
            if (collNode == null)
            {
                return;
            }

            var nodes = collNode.SelectNodes("postprocessor");

            for (int i = 0; i < nodes.Count; i++)
            {
                XmlNode        c = nodes[i];
                IPostProcessor p = ImportEngine.CreateObject <IPostProcessor> (c, engine, c);
                postProcessors.Add(p.Name, p);
            }
        }
コード例 #10
0
        private int keyToIndex(string key)
        {
            int ret;

            if (lenient)
            {
                if (lenientIndexes == null)
                {
                    lenientIndexes = new StringDict <int>(false);
                }
                if (lenientIndexes.TryGetValue(key, out ret))
                {
                    return(ret);
                }

                ret = -1;
                if (!selectiveExport)
                {
                    foreach (var kvp in lenientIndexes)
                    {
                        if (kvp.Value > ret)
                        {
                            ret = kvp.Value;
                        }
                    }
                    ret++;
                }
                lenientIndexes.Add(key, ret);
                return(ret);
            }
            String key2 = key;

            switch (key[0])
            {
            case 'f':
            case 'F':
                key2 = key.Substring(1); break;
            }

            if (int.TryParse(key2, NumberStyles.Integer, Invariant.Culture, out ret))
            {
                return(ret);
            }
            throw new BMException("Fieldname '{0}' should be a number or an 'F' with a number, to make sure that the field is written on the correct place in the CSV file.", key);
        }
コード例 #11
0
ファイル: Form1.cs プロジェクト: lanicon/ImportPipeline
        private void diagnose()
        {
            StringComparer cmp;
            bool           caseSens = checkBox1.Checked;

            cmp = caseSens ? StringComparer.Ordinal : StringComparer.OrdinalIgnoreCase;
            listBox1.Items.Clear();
            var dict       = new StringDict <int>(!caseSens);
            int cntPerItem = -1;

            for (int i = 0; i < lines.Count;)
            {
                String line = lines[i];
                int    existing;
                if (dict.TryGetValue(line, out existing))
                {
                    addMsg("Line {0} clashes with existing line {1}.", i, existing);
                }
                else
                {
                    dict.Add(line, i);
                }
                int start = i;
                for (i++; i < lines.Count; i++)
                {
                    String s = lines[i];
                    if (!cmp.Equals(s, line))
                    {
                        break;
                    }
                }
                int cnt = i - start;
                if (cntPerItem < 0)
                {
                    cntPerItem = cnt;
                }
                else if (cnt != cntPerItem)
                {
                    addMsg("Line {0}: unexpected count {1}, existing={2}.", start, cnt, cntPerItem);
                }
            }

            addMsg("Lines={0}, unique={1}, perUnique={2}. ", lines.Count, dict.Count, lines.Count / (double)dict.Count);
        }
コード例 #12
0
ファイル: MissedAdmin.cs プロジェクト: lanicon/ImportPipeline
        public void AddMissed(String x, bool touched = false)
        {
            if (x == null)
            {
                return;
            }

            x = x.ToLowerInvariant();
            if (dict == null)
            {
                dict = new StringDict <bool>();
                dict.Add(x, touched);
                return;
            }
            if (dict.ContainsKey(x))
            {
                return;
            }
            dict.Add(x, touched);
        }
コード例 #13
0
ファイル: Main.cs プロジェクト: nerochiaro/webcontent-cs
    static void Main(string[] args)
    {
        if (args.Length == 0) {
            Console.WriteLine("Either pass --server to run as XML-RPC server mode, or pass " +
                              "\"ServiceName [arg, arg...]\" to run directly.");
            return;
        }

        if (args.Length > 0 && args[0] == "--server") {
            int port = 9996;
            BlockingXmlRpcServer server = new BlockingXmlRpcServer(port);
            server.Start();
        } else {
            ProvidersManager providers = new ProvidersManager();
            Extractable service = null;
            try {
                service = providers.FindService(args[0]);
            }
            catch (InvalidNameException) {
                Console.WriteLine("The name of the service should be in the format NameSpace.ServiceName");
                return;
            }
            catch (ServiceNotFoundException) {
                Console.WriteLine("The service {0} is not currently supported.", args[0]);
                return;
            }

            StringDict arguments = new StringDict();
            if (args.Length > 1)
                for (int i = 1; i < args.Length; i++) {
                    string[] name_val = args[i].Split("=".ToCharArray(), 2);
                    if (name_val.Length > 1)
                        arguments.Add(name_val[0], name_val[1]);
                    else
                        Console.WriteLine("Wrong argument format, ignored: {0}", args[i]);
                }

            service.Extract(arguments);
            Console.WriteLine (service.ToString());
        }
    }
コード例 #14
0
ファイル: ScriptHost.cs プロジェクト: lanicon/ImportPipeline
        public void AddFile(String filename)
        {
            String fullName = Path.GetFullPath(filename);

            if (scripts.ContainsKey(fullName))
            {
                return;
            }

            ScriptFileAdmin a = new ScriptFileAdmin(fullName, templateSettings);

            scripts.Add(a.FileName, a);

            foreach (var asm in a.References)
            {
                AddReference(asm);
            }
            foreach (var incl in a.Includes)
            {
                AddFile(incl);
            }
        }
コード例 #15
0
ファイル: Pipeline.cs プロジェクト: lanicon/ImportPipeline
        /// <summary>
        /// Gets an existing endpoint from the cache or creates and initializes a new one.
        /// If a new endpoint is instantiated, its optionally wrapped by a list of postprocessors
        /// </summary>
        public IDataEndpoint CreateOrGetDataEndpoint(PipelineContext ctx, String name, String postProcessors)
        {
            String             endpointName = getEndpointName(name, ctx.DatasourceAdmin);
            EndpointCacheEntry epEntry;

            if (endPointCache == null)
            {
                endPointCache = new StringDict <EndpointCacheEntry>();
            }
            if (endPointCache.TryGetValue(endpointName, out epEntry))
            {
                if (postProcessors == null || String.Equals(postProcessors, epEntry.PostProcessors, StringComparison.OrdinalIgnoreCase))
                {
                    return(epEntry.Endpoint);
                }
                throw new BMException("Endpoint [{0}] is used with different post-processors [{1}] adn [{2}].", epEntry.Name, epEntry.PostProcessors, postProcessors);
            }

            IDataEndpoint ep = this.ImportEngine.Endpoints.GetDataEndpoint(ctx, endpointName);

            if (postProcessors == null)
            {
                postProcessors = DefaultPostProcessors;
            }
            if (postProcessors != null)
            {
                ep = wrapPostProcessors(ctx, ep, postProcessors);
            }
            epEntry = new EndpointCacheEntry(endpointName, ep, postProcessors);
            endPointCache.Add(endpointName, epEntry);

            if (started)
            {
                epEntry.Endpoint.Start(ctx);
            }
            return(epEntry.Endpoint);
        }
コード例 #16
0
        public ScriptExpressionHolder(List <String> customUsings = null)
        {
            className = "_ScriptExpressions";
            mem       = new MemoryStream();
            wtr       = mem.CreateTextWriter();
            StringDict usings = new StringDict();

            usings.Add("System", null);
            usings.Add("System.IO", null);
            usings.Add("System.Linq", null);
            usings.Add("System.Text", null);
            usings.Add("System.Xml", null);
            usings.Add("System.Collections.Generic", null);
            usings.Add("Bitmanager.Core", null);
            usings.Add("Bitmanager.IO", null);
            usings.Add("Bitmanager.Json", null);
            usings.Add("Bitmanager.Elastic", null);
            usings.Add("Bitmanager.ImportPipeline", null);
            usings.Add("Bitmanager.ImportPipeline.StreamProviders", null);
            usings.Add("Newtonsoft.Json.Linq", null);

            if (customUsings != null)
            {
                foreach (var u in customUsings)
                {
                    String uu = u;
                    if (uu.StartsWith("using "))
                    {
                        uu = u.Substring(6);
                    }
                    if (uu.EndsWith(";"))
                    {
                        uu = uu.Substring(0, uu.Length - 1);
                    }
                    uu         = uu.Trim();
                    usings[uu] = null;
                }
            }

            foreach (var kvp in usings)
            {
                wtr.Write("using ");
                wtr.Write(kvp.Key);
                wtr.WriteLine(";");
            }

            wtr.WriteLine();

            wtr.WriteLine("namespace Bitmanager.ImportPipeline");
            wtr.WriteLine("{");
            wtr.WriteLine("   public class _ScriptExpressions");
            wtr.WriteLine("   {");
        }
コード例 #17
0
ファイル: Translation.cs プロジェクト: sowa705/openchase
    public Translation()
    {
        Keys.Add("PART_Wheel", "Alloy rims");
        Keys.Add("PART_WheelCarbon", "Carbon rims");

        Keys.Add("PART_PaintRed", "Red");
        Keys.Add("PART_PaintGreen", "Green");
        Keys.Add("PART_PaintBlue", "Blue");
        Keys.Add("PART_PaintOrange", "Orange");
        Keys.Add("PART_PaintBlack", "Black");
        Keys.Add("PART_PaintGray", "Gray");
        Keys.Add("PART_PaintWhite", "White");
        Keys.Add("PART_PaintYellow", "Yellow");
        Keys.Add("PART_PaintMagenta", "Magenta");

        Keys.Add("PART_StickerBlue", "Blue");
        Keys.Add("PART_StickerBlack", "Black");
        Keys.Add("PART_StickerWhite", "White");
        Keys.Add("PART_StickerOrange", "Orange");

        Keys.Add("PART_NormalHeight", "Normal");
        Keys.Add("PART_HighHeight", "High");
        Keys.Add("PART_LowHeight", "Low");

        Keys.Add("PART_Spoiler2", "Spoiler 2");
        Keys.Add("PART_FrontSpoiler1", "Front spoiler 1");
        Keys.Add("PART_Spoiler3", "Spoiler 3");
        Keys.Add("PART_Spoiler4", "Spoiler 4");

        Keys.Add("PART_Intake1", "Air Intake");

        Keys.Add("PART_Numbers1", "Numbers 1");
        Keys.Add("PART_Numbers2", "Numbers 2");
        Keys.Add("PART_Sowirex", "Sowirex Trans-PolBud");
        Keys.Add("PART_StripeWide", "Wide stripe");
        Keys.Add("PART_StripeDouble", "Two stripes");

        Keys.Add("PART_PoliceLights", "Police lights");

        Keys.Add("PART_16d", "1.6 Diesel");
        Keys.Add("PART_19tdi", "1.9 Diesel");
        Keys.Add("PART_25tdi", "2.5 Diesel");
        Keys.Add("PART_36v6", "3.6 V6");
        Keys.Add("PART_50v8", "5.0 V8");
        Keys.Add("PART_72v12", "7.2 V12");

        Keys.Add("PART_BiTurbo", "Bi turbo");
        Keys.Add("PART_SingleTurbo", "Single turbo");

        Keys.Add("PART_LightShield", "Light shield");
        Keys.Add("PART_MediumShield", "Medium shield");
        Keys.Add("PART_HeavyShield", "Heavy shield");

        Keys.Add("PART_FWD", "FWD");
        Keys.Add("PART_RWD", "RWD");
        Keys.Add("PART_AWD", "AWD");

        Keys.Add("PART_Nose", "Nose");

        Keys.Add("PART_FBInterceptor", "Bullbar");

        Keys.Add("TYPE_PoliceLights", "Police lights");
        Keys.Add("TYPE_Spoiler", "Spoilers");
        Keys.Add("TYPE_FSpoiler", "Front spoilers");
        Keys.Add("TYPE_FBumper", "Front bumpers");

        Keys.Add("TYPE_SuspensionHeight", "Suspension height");
        Keys.Add("TYPE_AirIntake", "Air intakes");
        Keys.Add("TYPE_Wheels", "Wheels");

        Keys.Add("TYPE_Engine", "Engine");
        Keys.Add("TYPE_Turbo", "Turbo");
        Keys.Add("TYPE_Shield", "Shield");
        Keys.Add("TYPE_Drivetrain", "Drivetrain");

        Keys.Add("TYPE_BodyPaint", "Body paint");
        Keys.Add("TYPE_BaseSticker", "Base sticker");

        Keys.Add("TYPE_DecalSticker", "Decal");
        Keys.Add("TYPE_StickerPaint", "Sticker color");

        Keys.Add("CAR_sedan", "Interceptor");
        Keys.Add("CAR_bus", "Classic bus");
        Keys.Add("CAR_busnew", "Bus");
        Keys.Add("CAR_muscle", "Loader");

        Keys.Add("PART_null", "Remove part");
    }
コード例 #18
0
ファイル: Extractor.cs プロジェクト: nerochiaro/webcontent-cs
 public ExtractArguments(string name, string val)
 {
     args = new StringDict();
     args.Add(name, val);
 }
コード例 #19
0
 public new T Add(T item)
 {
     namedItems.Add(item.Name, item);
     base.Add(item);
     return(item);
 }