コード例 #1
0
 public void RegisterJoin(DataPath leftPath, DataPath rightPath)
 {
     TableInfo leftTable = InternalRegisterField(leftPath);
     TableInfo rightTable = InternalRegisterField(rightPath);
     DataPathJoin join = new DataPathJoin(leftPath.TargetTable, leftPath.TargetField, rightPath.TargetTable, rightPath.TargetField);
     leftTable.Joins[join] = rightTable;
 }
コード例 #2
0
        public static void Perform()
        {
            Log.Debug("Saving: Hotspots");
            var toysFolder = DataPath.Get("Hotspots");
            var hotspots   = GameDriver.Instance.HotSpots;

            foreach (var hotspot in hotspots)
            {
                var path = Path.Combine(toysFolder, hotspot.Name + ".json");
                JsonData.SerializeToFile(hotspot, path);
            }
        }
コード例 #3
0
        public string TranslateField(DataPath dataPath)
        {
            Guard.ArgumentNotNull(dataPath, "dataPath");
            string tableName = dataPath.RootTable;
            List<string> parts = new List<string>();

            foreach (DataPathJoin join in dataPath.Joins)
            {
                RelationshipInfo relationship;

                if (!_context.Relationships.TryGetValue(join, out relationship))
                {
                    throw new MigrationException(string.Format("Unable to find a relationship based on the '{0}' join string", join));
                }

                if (relationship.Relationship != null && relationship.IsOneToMany)
                {
                    throw new MigrationException(string.Format("Invalid join direction in '{0}' join string", join));
                }

                parts.Add(relationship.PropertyName);
                tableName = join.ToTable;
            }

            OrmEntity entity;

            if (!_context.Entities.TryGetValue(tableName, out entity))
            {
                throw new MigrationException(string.Format("Unable to resolve the entity for '{0}' table", tableName));
            }

            string targetField = dataPath.TargetField;

            if (targetField.StartsWith("@"))
            {
                targetField = targetField.Substring(1);
            }

            OrmEntityProperty property = entity.Properties.GetFieldPropertyByFieldName(targetField);

            if (property == null)
            {
                throw new MigrationException(string.Format("Unable to resolve property for field '{0}' in '{1}' entity", targetField, entity.Name));
            }

            string propertyName = (property == entity.KeyProperty
                                       ? "Id"
                                       : property.PropertyName);
            parts.Add(propertyName);
            return string.Join(".", parts.ToArray());
        }
コード例 #4
0
        private void Make_TreeList_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog FilePath = new FolderBrowserDialog
            {
                Description = "请选择包含数据存储路径"
            };

            if (FilePath.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                path = FilePath.SelectedPath;
            }
            _GetButtonPath = DataPath.VIBMACHINE;
            PaintTreeView(path);
        }
コード例 #5
0
 protected override string BuildDataField(DataPath prefixPath)
 {
     try
     {
         return (_isObject
                     ? DataPathTranslator.TranslateReference(BindingPath, "USERSECURITY", "USERID")
                     : DataPathTranslator.TranslateField(BindingPath));
     }
     catch (MigrationException ex)
     {
         LogError(ex.Message);
         return null;
     }
 }
コード例 #6
0
        private void TarimDataToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog FilePath = new FolderBrowserDialog
            {
                Description = "请选择包含塔里木数据所在路径"
            };

            if (FilePath.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                path = FilePath.SelectedPath;
            }
            _GetButtonPath = DataPath.TARIMEMERSON;
            PaintTreeView(path);
        }
コード例 #7
0
        private ServerListViewItem[] LoadDescriptors()
        {
            List <ServerDescription> rv;

            try {
                rv = XmlHelper.FromFile <List <ServerDescription> >(DataPath.Combine(descriptorFile));
            }
            catch (Exception) {
                rv = Config.Descriptors;
            }
            return((from d in rv
                    let i = new ServerListViewItem(httpServer, cacheFile, d)
                            select i).ToArray());
        }
コード例 #8
0
        public static string GetConnectionString(this Repository repository)
        {
            var dataPath = new DataPath(repository.Name);
            var dataFile = Path.Combine(dataPath.PhysicalPath, repository.Name + ".sdf");

            var connectionString = string.Format("Data Source={0};Persist Security Info=False;", dataFile);

            if (!File.Exists(dataFile))
            {
                DatabaseHelper.CreateDatabase(dataFile, connectionString);
                SchemaManager.InitializeDatabase(repository);
            }
            return(connectionString);
        }
コード例 #9
0
        public static void Start()
        {
            #if !DEBUG
            try
            #endif
            {
                if (SingleInstanceApplication)
                {
                    solitude = new Solitude("TheMeldingWars." + Name, CommandHandler);

                    if (!solitude.FirstInstance)
                    {
                        return;
                    }
                }


                if (!Common.IsDebugging())
                {
                    string[] args = Environment.GetCommandLineArgs();
                    if (!DataPath.Equals(Path.GetDirectoryName(args[0]), StringComparison.CurrentCultureIgnoreCase))
                    {
                        string here  = args[0];
                        string there = Path.Combine(DataPath, Name + ".exe");

                        if (File.Exists(there))
                        {
                            File.Delete(there);
                        }
                        File.Copy(here, there);
                        Common.Execute(there, Environment.CommandLine);
                        Environment.Exit(0);
                    }
                }
                else
                {
                    Cmd?.Invoke(Environment.GetCommandLineArgs().ToList());
                }

                AppDomain.CurrentDomain.ProcessExit += new EventHandler(ExitHandler);
                Run?.Invoke();
            }
            #if !DEBUG
            catch (Exception ex)
            {
                ErrorHandler(null, new UnhandledExceptionEventArgs(ex, true));
            }
            #endif
        }
コード例 #10
0
 private void AddJsonElementValuesToDataHub(DataHub dataHub, DataPath basePath, JsonElement jsonElement)
 {
     if (jsonElement.ValueKind == JsonValueKind.Object)
     {
         foreach (var jsonProperty in jsonElement.EnumerateObject())
         {
             var path = DataPath.Combine(basePath, new DataPath(jsonProperty.Name));
             AddJsonElementValuesToDataHub(dataHub, path, jsonProperty.Value);
         }
     }
     else
     {
         dataHub.Add(basePath, GetJsonElementValue(jsonElement));
     }
 }
コード例 #11
0
        public TextureBank Initialize(GameDriver driver)
        {
            Log.Message("Initializing: Texture Bank");
            _textures = new Dictionary <string, Texture2D>();

            var pathMapPath = DataPath.Get("TextureBank.json");
            var pathMap     = JsonData.DeserializeFromFile <StringConfiguration>(pathMapPath);

            foreach (var entry in pathMap)
            {
                var texture = driver.Content.Load <Texture2D>(entry.Value);
                _textures.Add(entry.Key, texture);
            }

            return(this);
        }
コード例 #12
0
        public override bool GetStringFromDataPath(DataPath dp, out string result)
        {
            if (!base.GetStringFromDataPath(dp, out result))
            {
                if (dp == DataPath.FlavorText)
                {
                    result = Flavor;
                }
                else
                {
                    return(false);
                }
            }

            return(true);
        }
コード例 #13
0
 public virtual bool GetIntFromDataPath(DataPath dp, out int result)
 {
     if (dp == DataPath.ID)
     {
         result = ID;
     }
     else if (dp == DataPath.NoraCost)
     {
         result = NoraCost;
     }
     else
     {
         result = 0;
         return(false);
     }
     return(true);
 }
コード例 #14
0
 public virtual bool GetStringFromDataPath(DataPath dp, out string result)
 {
     if (dp == DataPath.Name)
     {
         result = Name;
     }
     else if (dp == DataPath.Description)
     {
         result = Description;
     }
     else
     {
         result = "";
         return(false);
     }
     return(true);
 }
コード例 #15
0
        internal async ValueTask <DataStream <T> > OpenStreamAsync <T>(DataPath dataPath)
        {
            var mdr = await MetadataManager.GetMetadataRecordByPathAsync(dataPath).ConfigureAwait(false);

            if (mdr.PK != null)
            {
                var containerId = mdr.ContainerId;
                var streamId    = StreamLogId.ContainerIdToStreamId(containerId);
                var slid        = new StreamLogId(mdr.RepoId, streamId);

                var sl = StreamLogManager.OpenStreamLog(slid, textId: dataPath.ToString());
                var ds = new DataStream <T>(new DataStreamCursor <T>(sl.GetCursor()), mdr.Metadata);
                return(ds);
            }

            throw new KeyNotFoundException($"Data stream {dataPath} does not exist.");
        }
コード例 #16
0
ファイル: ModEditor.cs プロジェクト: peterhaneve/ONIMods
        public void PresetFields()
        {
            string basePath = REG_PREFIX + ID.ToString();

            DataPath = Registry.CurrentUser.GetSubKeyValue(basePath, "DataFolder")?.
                       ToString() ?? "";
            Description = details.m_rgchDescription?.Trim() ?? "";
            PreviewPath = Registry.CurrentUser.GetSubKeyValue(basePath, "PreviewImg")?.
                          ToString() ?? "";
            Title = details.m_rgchTitle?.Trim() ?? "";
            string patchInfo = "(1.0.0.0) Initial release";

            if (!DataPath.IsNullOrWhiteSpace())
            {
                patchInfo = PopulatePatchInfo(DataPath) ?? patchInfo;
            }
            PatchInfo = patchInfo;
        }
コード例 #17
0
        public void LoadJsonResources(DataHub dataHub, Assembly assembly,
                                      Regex regex, bool includeResourceName = true, DataPath?basePath = null)
        {
            var resourceNames = embeddedResourceUtils.GetLocalEmbeddedResourceNames(assembly, regex);

            foreach (var resourceName in resourceNames)
            {
                var content     = embeddedResourceUtils.GetLocalEmbeddedResourceText(assembly, resourceName);
                var contentPath = new DataPath(regex.Match(resourceName).Groups[1].Value.Split('.'));

                var fullBasePath = includeResourceName
                        ? DataPath.Combine(basePath, contentPath)
                        : basePath ?? DataPath.Empty;

                using var jsonDocument = JsonDocument.Parse(content);
                AddJsonElementValuesToDataHub(dataHub, fullBasePath, jsonDocument.RootElement);
            }
        }
コード例 #18
0
        private void SaveConfig()
        {
            try {
                var descs = (from ServerListViewItem item in listDescriptions.Items
                             select item.Description).ToArray();

                var file = DataPath.Combine(descriptorFile + ".tmp");
                XmlHelper.ToFile(descs, file);

                var outfile = DataPath.Combine(descriptorFile);
                File.Copy(file, outfile, true);
                File.Delete(file);
            }
            catch (Exception ex) {
                log.Error("Failed to write descriptors", ex);
            }
            Config.Save();
        }
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (VaultUri != null ? VaultUri.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (int)AuthenticationType;
         hashCode = (hashCode * 397) ^ (RoleId != null ? RoleId.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (SecretId != null ? SecretId.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Username != null ? Username.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Password != null ? Password.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Token != null ? Token.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (int)SecretsEngine;
         hashCode = (hashCode * 397) ^ (SecretsEnginePath != null ? SecretsEnginePath.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (DataPath != null ? DataPath.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Namespace != null ? Namespace.GetHashCode() : 0);
         return(hashCode);
     }
 }
コード例 #20
0
        // TODO

        public virtual void SetPaths(IAbsoluteDirectoryPath appPath        = null, IAbsoluteDirectoryPath dataPath = null,
                                     IAbsoluteDirectoryPath localDataPath  = null, IAbsoluteDirectoryPath tempPath = null,
                                     IAbsoluteDirectoryPath configPath     = null, IAbsoluteDirectoryPath toolPath = null,
                                     IAbsoluteDirectoryPath sharedDataPath = null)
        {
            //if (PathsSet) throw new Exception("Paths are already set!");
            if (PathsSet)
            {
                this.Logger().Debug("Paths were already set!");
            }

            EntryLocation = CommonBase.AssemblyLoader.GetEntryLocation();
            EntryPath     = CommonBase.AssemblyLoader.GetEntryPath();
            ProcessExtensions.DefaultWorkingDirectory = EntryPath;
            AppPath             = appPath ?? GetAppPath();
            DataPath            = dataPath ?? GetDataPath();
            NotePath            = DataPath.GetChildDirectoryWithName("Notes");
            LocalDataRootPath   = GetLocalDataRootPath();
            LocalDataPath       = localDataPath ?? GetLocalDataPath();
            LocalDataSharedPath = sharedDataPath ?? GetLocalDataSharedPath();
            SharedDllPath       = GetLocalSharedDllPath();
            LogPath             = LocalDataPath.GetChildDirectoryWithName("Logs");
            TempPath            = tempPath ??
                                  Path.Combine(Path.GetTempPath(), Common.AppCommon.ApplicationName)
                                  .ToAbsoluteDirectoryPath();
            ToolPath          = toolPath ?? LocalDataSharedPath.GetChildDirectoryWithName("Tools");
            ToolMinGwBinPath  = ToolPath.GetChildDirectoryWithName("mingw").GetChildDirectoryWithName("bin");
            ToolCygwinBinPath = ToolPath.GetChildDirectoryWithName("cygwin").GetChildDirectoryWithName("bin");
            ConfigPath        = configPath ?? ToolPath.GetChildDirectoryWithName("Config");
            StartPath         = Directory.GetCurrentDirectory().ToAbsoluteDirectoryPath();

            AwesomiumPath = LocalDataSharedPath.GetChildDirectoryWithName("CEF");

            MyDocumentsPath = GetMyDocumentsPath();
            ProgramDataPath = GetProgramDataPath();
            SharedFilesPath = AppPath;

            ServiceExePath     = Common.IsMini ? EntryLocation : SharedFilesPath.GetChildFileWithName(ServiceExe);
            SelfUpdaterExePath = SharedFilesPath.GetChildFileWithName(SelfUpdaterExe);

            SynqRootPath = ProgramDataPath.GetChildDirectoryWithName("Synq");

            PathsSet = true;
        }
コード例 #21
0
 public void Validate()
 {
     if (DataPath.Last() != System.IO.Path.DirectorySeparatorChar)
     {
         throw new System.Exception($"DataPath {DataPath} must end with {System.IO.Path.DirectorySeparatorChar}.");
     }
     if (!System.IO.Directory.Exists(DataPath))
     {
         throw new System.Exception($"DataPath does not exist.");
     }
     if (!File.Exists(WebConfigPath))
     {
         throw new System.Exception($"WebConfigPath does not exist.");
     }
     if (SnapShotFile.Length == 0 && SnapShotPath.Length != 0)
     {
         throw new System.Exception($"SnapShotFile is missing.");
     }
     if (SnapShotFile.Length != 0 && SnapShotPath.Length == 0)
     {
         throw new System.Exception($"SnapShotPath is missing.");
     }
     if (LogPath.Length == 0 && LogFilesRaw.Length != 0)
     {
         throw new System.Exception($"LogPath is missing.");
     }
     if (LogPath.Length != 0 && LogFilesRaw.Length == 0)
     {
         throw new System.Exception($"LogFiles is missing.");
     }
     if (AuthSalt == null)
     {
         throw new System.Exception($"AuthSalt is missing.");
     }
     if (AuthToken == null)
     {
         throw new System.Exception($"AuthToken is missing.");
     }
     if (Secret.Length == 0)
     {
         throw new System.Exception($"Secret is missing.");
     }
 }
コード例 #22
0
        public override bool GetIntFromDataPath(DataPath dp, out int result)
        {
            if (!base.GetIntFromDataPath(dp, out result))
            {
                if (dp == DataPath.DeckLimit)
                {
                    result = DeckLimit;
                }
                else if (dp == DataPath.Cooldown)
                {
                    result = Cooldown;
                }
                else
                {
                    return(false);
                }
            }

            return(true);
        }
コード例 #23
0
        internal async ValueTask <DataStreamWriter <T> > OpenStreamWriterAsync <T>(DataPath dataPath,
                                                                                   WriteMode writeMode = WriteMode.LocalSync,
                                                                                   int rateHint        = 0)
        {
            var mdr = await MetadataManager.GetMetadataRecordByPathAsync(dataPath).ConfigureAwait(false);

            if (mdr.PK != null)
            {
                var containerId = mdr.ContainerId;
                var streamId    = StreamLogId.ContainerIdToStreamId(containerId);
                var slid        = new StreamLogId(mdr.RepoId, streamId);

                var sl = StreamLogManager.OpenStreamLog(slid, rateHint, dataPath.ToString());
                // var state = StreamLogManager.StateStorage.GetState(slid);
                var writer = new DataStreamWriter <T>(sl, KeySorting.NotEnforced, writeMode);
                return(writer);
            }

            throw new KeyNotFoundException($"Data stream {dataPath} does not exist.");
        }
コード例 #24
0
        public override bool GetEnumListFromDataPath(DataPath dp, out List <string> result)
        {
            if (!base.GetEnumListFromDataPath(dp, out result))
            {
                if (dp == DataPath.Class)
                {
                    result = Class;
                }
                else if (dp == DataPath.Race)
                {
                    result = Race;
                }
                else
                {
                    return(false);
                }
            }

            return(true);
        }
コード例 #25
0
        public override bool GetEnumFromDataPath(DataPath dp, out string result)
        {
            if (!base.GetEnumFromDataPath(dp, out result))
            {
                if (dp == DataPath.Rarity)
                {
                    result = Rarity;
                }
                else if (dp == DataPath.Expansion)
                {
                    result = Expansion;
                }
                else
                {
                    return(false);
                }
            }

            return(true);
        }
コード例 #26
0
ファイル: ChainFunctionMetadata.cs プロジェクト: wyk125/AElf
        /// <summary>
        /// //TODO: in fact, only public interface of contact need to be added into FunctionMetadataMap
        /// </summary>
        /// <param name="chainId"></param>
        /// <param name="contractAddr"></param>
        /// <param name="contractMetadataTemplate"></param>
        /// <exception cref="FunctionMetadataException"></exception>
        public async Task DeployNewContract(Hash chainId, Address contractAddr, ContractMetadataTemplate contractMetadataTemplate)
        {
            Dictionary <string, FunctionMetadata> tempMap = new Dictionary <string, FunctionMetadata>();

            try
            {
                var globalCallGraph = await GetCallingGraphForChain(chainId);

                var newCallGraph = TryUpdateAndGetCallingGraph(chainId, contractAddr, globalCallGraph, contractMetadataTemplate);

                foreach (var localFuncName in contractMetadataTemplate.ProcessFunctionOrder)
                {
                    var funcNameWithAddr =
                        Replacement.ReplaceValueIntoReplacement(localFuncName, Replacement.This,
                                                                contractAddr.DumpHex());
                    var funcMetadata = await GetMetadataForNewFunction(chainId, funcNameWithAddr,
                                                                       contractMetadataTemplate.MethodMetadataTemplates[localFuncName],
                                                                       contractAddr, contractMetadataTemplate.ContractReferences, tempMap);

                    tempMap.Add(funcNameWithAddr, funcMetadata);
                }

                //if no exception is thrown, merge the tempMap into FunctionMetadataMap and update call graph in database
                await _dataStore.InsertAsync(chainId.OfType(HashType.CallingGraph),
                                             SerializeCallingGraph(newCallGraph));

                foreach (var functionMetadata in tempMap)
                {
                    FunctionMetadataMap.Add(functionMetadata.Key, functionMetadata.Value);

                    await _dataStore.InsertAsync(
                        DataPath.CalculatePointerForMetadata(chainId, functionMetadata.Key),
                        functionMetadata.Value);
                }
            }
            catch (FunctionMetadataException e)
            {
                _logger?.Error(e, "Exception while deploy new contract.");
                throw;
            }
        }
コード例 #27
0
ファイル: ChainFunctionMetadata.cs プロジェクト: wyk125/AElf
        /// <summary>
        ///
        /// </summary>
        /// <param name="chainId"></param>
        /// <param name="functionFullName"></param>
        /// <returns></returns>
        /// <exception cref="InvalidParameterException"></exception>
        public async Task <FunctionMetadata> GetFunctionMetadata(Hash chainId, string functionFullName)
        {
            //BUG: if the smart contract can be updated, then somehow this in-memory cache FunctionMetadataMap need to be updated too. Currently the ChainFunctionMetadata has no way to know some metadata is updated; current thought is to request current "previous block hash" every time the ChainFunctionMetadata public interface got executed, that is "only use cache when in the same block, can clear the cache per block"
            if (!FunctionMetadataMap.TryGetValue(functionFullName, out var txMetadata))
            {
                var data = await _dataStore.GetAsync <FunctionMetadata>(DataPath.CalculatePointerForMetadata(chainId, functionFullName));

                if (data != null)
                {
                    txMetadata = data;
                    FunctionMetadataMap.Add(functionFullName, txMetadata);
                }
                else
                {
                    throw new InvalidParameterException("There are no function named " + functionFullName +
                                                        " in the FunctionMetadataMap");
                }
            }

            return(txMetadata);
        }
コード例 #28
0
ファイル: DataPathTests.cs プロジェクト: hthubert/DataSpreads
        public void CouldValidateDataPath()
        {
            Assert.IsTrue(DataPath.TryValidate("a/b/c", out _, out _));
            Assert.IsTrue(DataPath.TryValidate("_", out _, out _));
            Assert.IsTrue(DataPath.TryValidate("@a/b/", out _, out _));
            Assert.IsTrue(DataPath.TryValidate("/a/b/@c/", out var rewritten, out _));
            Assert.AreEqual("@c/a/b", rewritten);
            Assert.IsTrue(DataPath.TryValidate("@my/a/b/", out rewritten, out _));
            Assert.AreEqual("~/a/b", rewritten);
            Assert.IsTrue(DataPath.TryValidate("~/a/b/", out _, out _));
            Assert.IsTrue(DataPath.TryValidate("sdvFSbdvfju.eegb.ewg-weg.___degewbg.dfs", out _, out _));


            Assert.IsTrue(DataPath.TryValidate("a.b", out _, out _));

            Assert.IsFalse(DataPath.TryValidate("~a/b/", out _, out _));
            Assert.IsFalse(DataPath.TryValidate(".", out _, out _));
            Assert.IsFalse(DataPath.TryValidate("..", out _, out _));
            Assert.IsFalse(DataPath.TryValidate("-", out _, out _));
            Assert.IsFalse(DataPath.TryValidate("--", out _, out _));
        }
コード例 #29
0
        public static void Perform()
        {
            var toy = new Toy
            {
                Name         = "TestToy",
                LargeSprite  = GenerateSprite.Default(),
                DamagePoints = new List <ToyDamagePoint>
                {
                    new ToyDamagePoint
                    {
                        Active = true,
                        Type   = "BurstSeam",
                        Sprite = GenerateSprite.Default()
                    },
                }
            };

            var path = DataPath.Get("Toys\\TestToy.json");

            JsonData.SerializeToFile(toy, path);
        }
コード例 #30
0
        public static void Shutdown()
        {
            View.StatusUpdate(StatusModel.StartStopWatch);
            View.StatusUpdate(StatusModel.Update("Closing"));

            // ReSharper disable AssignNullToNotNullAttribute
            var configFile = DataPath.GetConfigFilePath();
            // ReSharper restore AssignNullToNotNullAttribute

            var path = Path.GetDirectoryName(configFile);

            if (path != null)
            {
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
            }
            else
            {
                throw new Exception("DockPanel.config path is null");
            }

            if (SkipSaveLayout)
            {
                if (File.Exists(configFile))
                {
                    File.Delete(configFile);
                }
            }
            else
            {
                View.DockPanel.SaveAsXml(configFile);
            }

            SaveRestoreOpenDocuments();

            XmlDal.Save();
        }
コード例 #31
0
        public override bool GetAbilityListFromDataPath(DataPath dp, out List <Ability> result)
        {
            if (dp == DataPath.AllAbilities)
            {
                result = AllAbilities_refs;
            }
            else if (dp == DataPath.BaseAbilities)
            {
                result = BaseAbilities_refs;
            }
            else if (dp == DataPath.UpgradeAbilities)
            {
                result = AllUpgradeAbilities_refs;
            }
            else
            {
                result = null;
                return(false);
            }

            return(true);
        }
コード例 #32
0
        public void FstProcessor_Rusmarc()
        {
            IrbisConnection connection = Connection.ThrowIfNull();
            IrbisProvider   provider   = new ConnectedClient(connection);

            FileSpecification specification = new FileSpecification
                                              (
                IrbisPath.MasterFile,
                "IBIS",
                "rmarci.fst"
                                              );
            FstProcessor processor = new FstProcessor(provider, specification);

            MarcRecord record;
            string     fileName = Path.Combine
                                  (
                DataPath.ThrowIfNull("DataPath"),
                "TEST1.ISO"
                                  );

            using (Stream stream = File.OpenRead(fileName))
            {
                record = Iso2709.ReadRecord
                         (
                    stream,
                    IrbisEncoding.Ansi
                         )
                         .ThrowIfNull("Iso2709.ReadRecord");
            }
            MarcRecord transformed = processor.TransformRecord
                                     (
                record,
                processor.File
                                     );

            Write(transformed);
        }
コード例 #33
0
ファイル: BlockManagerBasic.cs プロジェクト: wyk125/AElf
        public async Task <Block> GetBlockByHeight(Hash chainId, ulong height)
        {
            _logger?.Trace($"Trying to get block by height {height}.");

            var key = DataPath.CalculatePointerForGettingBlockHashByHeight(chainId, height);

            if (key == null)
            {
                _logger?.Error($"Invalid block height - {height}.");
                return(null);
            }

            var blockHash = await _dataStore.GetAsync <Hash>(key);

            var blockHeader = await _dataStore.GetAsync <BlockHeader>(blockHash.OfType(HashType.BlockHeaderHash));

            var blockBody = await _dataStore.GetAsync <BlockBody>(blockHash.OfType(HashType.BlockBodyHash));

            return(new Block
            {
                Header = blockHeader,
                Body = blockBody
            });
        }
コード例 #34
0
        private string InternalTranslate(DataPath dataPath, string targetTable, string targetField, bool isOneToMany)
        {
            Guard.ArgumentNotNull(dataPath, "dataPath");
            Guard.ArgumentNotNull(targetTable, "targetTable");
            Guard.ArgumentNotNull(targetField, "targetField");
            int joinCount = dataPath.Joins.Count;
            List<string> parts = new List<string>();
            RelationshipInfo relationship;

            for (int i = 0; i < joinCount; i++)
            {
                DataPathJoin join = dataPath.Joins[i];

                if (!_context.Relationships.TryGetValue(join, out relationship))
                {
                    throw new MigrationException(string.Format("Unable to find a relationship based on the '{0}' join string", join));
                }

                if (!(i == joinCount - 1 &&
                      StringUtils.CaseInsensitiveEquals(join.ToTable, targetTable) &&
                      StringUtils.CaseInsensitiveEquals(join.ToField, targetField)))
                {
                    Debug.Assert(!relationship.IsOneToMany);
                    parts.Add(relationship.PropertyName);
                }
            }

            DataPathJoin targetJoin = new DataPathJoin(dataPath.TargetTable, dataPath.TargetField, targetTable, targetField);

            if (!_context.Relationships.TryGetValue(targetJoin, out relationship))
            {
                throw new MigrationException(string.Format("Unable to find a relationship based on the '{0}' join string", targetJoin));
            }

            Debug.Assert(relationship.IsOneToMany == isOneToMany);
            parts.Add(relationship.PropertyName);
            return string.Join(".", parts.ToArray());
        }
コード例 #35
0
        protected override void OnExtractSchemaHints()
        {
            DelphiComponent query = Component.Components[0];

            if (query.TryGetPropertyValue("MainTable", out _tableName) && !string.IsNullOrEmpty(_tableName))
            {
                DataPathTranslator.RegisterTable(_tableName);
            }

            string bindCondition;

            if (query.TryGetPropertyValue("BindCondition", out bindCondition) && !string.IsNullOrEmpty(bindCondition))
            {
                try
                {
                    _bindConditionPath = DataPath.Parse(bindCondition);
                }
                catch (FormatException)
                {
                    LogError("Unable to parse '{0}' bind condition", bindCondition);
                }

                if (_bindConditionPath != null)
                {
                    if (_bindIdBindingPath != null)
                    {
                        DataPathTranslator.RegisterJoin(_bindIdBindingPath, _bindConditionPath);
                    }

                    _columnPrefixPath = _bindConditionPath.Reverse();
                    DataPathTranslator.RegisterField(_columnPrefixPath);
                }
            }

            _columns = new List<ColumnDefinition>();
            _dataPaths = new List<DataPath>();

            IEnumerable layouts;

            if (query.TryGetPropertyValue("Layouts.Strings", out layouts))
            {
                foreach (string layout in layouts)
                {
                    ColumnDefinition column = ColumnDefinition.Parse(layout);

                    if (column.Visible)
                    {
                        DataPath dataPath = null;

                        try
                        {
                            dataPath = DataPath.Parse(column.Binding);
                        }
                        catch (FormatException)
                        {
                            LogError("Unable to parse '{0}' column binding string", column.Binding);
                        }

                        if (dataPath != null)
                        {
                            DataPathTranslator.RegisterField(dataPath);
                            _columns.Add(column);
                            _dataPaths.Add(dataPath);
                        }
                    }
                }
            }
        }
コード例 #36
0
 protected virtual string BuildDataField(DataPath prefixPath)
 {
     try
     {
         return _dataPathTranslator.TranslateField(_bindingPath, prefixPath);
     }
     catch (MigrationException ex)
     {
         LogError(ex.Message);
         return null;
     }
 }
コード例 #37
0
        public void ExtractSchemaHints()
        {
            string dataPath;

            if (_component.TryGetPropertyValue("DataPath", out dataPath) && !string.IsNullOrEmpty(dataPath))
            {
                try
                {
                    _bindingPath = DataPath.Parse(dataPath);
                }
                catch (FormatException)
                {
                    LogError("Unable to parse '{0}' colunn data path", dataPath);
                }

                if (_bindingPath != null)
                {
                    _dataPathTranslator.RegisterField(_bindingPath);
                }
            }

            OnExtractSchemaHints();
        }
コード例 #38
0
 public string TranslateCollection(DataPath dataPath, string targetTable, string targetField)
 {
     return InternalTranslate(dataPath, targetTable, targetField, true);
 }
コード例 #39
0
        protected override void OnExtractSchemaHints()
        {
            if (Component.TryGetPropertyValue("TableName", out _tableName) && !string.IsNullOrEmpty(_tableName))
            {
                DataPathTranslator.RegisterTable(_tableName);
            }

            string bindCondition;

            if (Component.TryGetPropertyValue("BindCondition", out bindCondition) && !string.IsNullOrEmpty(bindCondition))
            {
                try
                {
                    _bindConditionPath = DataPath.Parse(bindCondition);
                }
                catch (FormatException)
                {
                    LogError("Unable to parse '{0}' bind condition", bindCondition);
                }

                if (_bindConditionPath != null)
                {
                    if (_bindIdBindingPath != null)
                    {
                        DataPathTranslator.RegisterJoin(_bindIdBindingPath, _bindConditionPath);
                    }

                    _columnPrefixPath = _bindConditionPath.Reverse();
                    DataPathTranslator.RegisterField(_columnPrefixPath);
                }
            }

            _columnBuilders = new List<ColumnBuilder>(Component.Components.Count);

            foreach (DelphiComponent columnComponent in Component.Components)
            {
                bool visible;

                if (!columnComponent.TryGetPropertyValue("Visible", out visible) || visible)
                {
                    ColumnBuilder builder = ColumnBuilder.CreateBuilder(columnComponent);

                    if (builder != null)
                    {
                        _workItem.BuildTransientItem(builder);
                        builder.ExtractSchemaHints();
                        _columnBuilders.Add(builder);
                    }
                    else
                    {
                        LogWarning("Legacy column type '{0}' not supported", columnComponent.Type);
                    }
                }
            }
        }
コード例 #40
0
 public void RegisterField(DataPath dataPath)
 {
     InternalRegisterField(dataPath);
 }
コード例 #41
0
        private TableInfo InternalRegisterField(DataPath dataPath)
        {
            Guard.ArgumentNotNull(dataPath, "dataPath");
            TableInfo table = InternalRegisterTable(dataPath.RootTable);

            foreach (DataPathJoin join in dataPath.Joins)
            {
                table.Columns.Add(join.FromField);
                TableInfo nextTable;

                if (!table.Joins.TryGetValue(join, out nextTable))
                {
                    nextTable = InternalRegisterTable(join.ToTable);
                    table.Joins.Add(join, nextTable);
                }

                table = nextTable;
                table.Columns.Add(join.ToField);
            }

            table.Columns.Add(dataPath.TargetField);
            return table;
        }
コード例 #42
0
 public string TranslateReference(DataPath dataPath, string targetTable, string targetField)
 {
     return InternalTranslate(dataPath, targetTable, targetField, false);
 }
コード例 #43
0
        public string TranslateField(DataPath dataPath, DataPath prefixPath)
        {
            Guard.ArgumentNotNull(dataPath, "dataPath");

            if (prefixPath != null && prefixPath.Joins.Count > 0)
            {
                Debug.Assert(prefixPath.TargetTable == dataPath.RootTable);
                DataPath newDataPath = new DataPath(prefixPath.RootTable, dataPath.TargetField);

                foreach (DataPathJoin join in prefixPath.Joins)
                {
                    newDataPath.Joins.Add(join);
                }

                foreach (DataPathJoin join in dataPath.Joins)
                {
                    newDataPath.Joins.Add(join);
                }

                dataPath = newDataPath;
            }

            return TranslateField(dataPath);
        }
コード例 #44
0
        protected override void OnExtractSchemaHints()
        {
            DataPath textBindingPath;

            if (Control.Bindings != null)
            {
                Control.Bindings.TryGetValue(LookupIdBindingCode, out _lookupIdBindingPath);
                Control.Bindings.TryGetValue(TextBindingCode, out textBindingPath);
            }
            else
            {
                textBindingPath = null;
            }

            string lookupDef;

            if (Component.TryGetPropertyValue("Lookup", out lookupDef))
            {
                _lookup = EntityLoader.LoadLookup(lookupDef);

                if (_lookup != null)
                {
                    try
                    {
                        _idDataPath = DataPath.Parse(_lookup.IdField);
                    }
                    catch (FormatException)
                    {
                        LogError("Unable to parse '{0}' lookup id field", _lookup.IdField);
                    }

                    try
                    {
                        _nameDataPath = DataPath.Parse(_lookup.NameField);
                    }
                    catch (FormatException)
                    {
                        LogError("Unable to parse '{0}' lookup name field", _lookup.NameField);
                    }

                    DataPathTranslator.RegisterTable(_lookup.MainTable);

                    if (_idDataPath != null)
                    {
                        _columnPrefixPath = _idDataPath.Reverse();
                        DataPathTranslator.RegisterField(_idDataPath);
                        DataPathTranslator.RegisterField(_columnPrefixPath);
                    }

                    if (_nameDataPath != null)
                    {
                        DataPathTranslator.RegisterField(_nameDataPath);
                    }

                    _columns = new List<ColumnDefinition>();
                    _dataPaths = new List<DataPath>();

                    if (_lookup.Layout != null)
                    {
                        foreach (string columnString in _lookup.Layout.Split(new char[] {'\r', '\n'}, StringSplitOptions.RemoveEmptyEntries))
                        {
                            ColumnDefinition column = ColumnDefinition.Parse(columnString);

                            if (column.Visible)
                            {
                                DataPath dataPath = null;

                                try
                                {
                                    dataPath = DataPath.Parse(column.Binding);
                                }
                                catch (FormatException)
                                {
                                    LogError("Unable to parse '{0}' column binding string", column.Binding);
                                }

                                if (dataPath != null)
                                {
                                    DataPathTranslator.RegisterField(dataPath);
                                    _columns.Add(column);
                                    _dataPaths.Add(dataPath);
                                }
                            }
                        }
                    }
                }
                else
                {
                    LogWarning("Unable to find '{0}' lookup", lookupDef);
                }
            }

            if (_lookupIdBindingPath != null && _idDataPath != null)
            {
                if (textBindingPath != null &&
                    _nameDataPath != null &&
                    textBindingPath.Joins.Count == 0)
                {
                    Debug.Assert(_lookupIdBindingPath.Joins.Count == 0);
                    Debug.Assert(_idDataPath.Joins.Count == 0);
                    Debug.Assert(_nameDataPath.Joins.Count == 0);
                    DataPathTranslator.RegisterJoin(_lookupIdBindingPath, _idDataPath);
                    Context.SecondaryJoins[
                        new DataPathJoin(_lookupIdBindingPath.TargetTable, _lookupIdBindingPath.TargetField, _idDataPath.TargetTable, _idDataPath.TargetField)] =
                        new DataPathJoin(textBindingPath.TargetTable, textBindingPath.TargetField, _nameDataPath.TargetTable, _nameDataPath.TargetField);
                    _isObject = true;
                }

                if (!_isObject)
                {
                    OrmEntity entity = EntityLoader.LoadEntity(_lookupIdBindingPath.TargetTable);

                    if (entity != null)
                    {
                        string targetField = _lookupIdBindingPath.TargetField;

                        if (targetField.StartsWith("@"))
                        {
                            targetField = targetField.Substring(1);
                        }

                        OrmEntityProperty property = entity.Properties.GetFieldPropertyByFieldName(targetField);

                        if (property != null)
                        {
                            _isObject = !property.Include;
                        }
                    }
                }

                if (_isObject)
                {
                    DataPathTranslator.RegisterJoin(_idDataPath, _lookupIdBindingPath);
                }
            }
        }
コード例 #45
0
        public void Build(DataPath prefixPath)
        {
            if (_bindingPath != null)
            {
                string propertyString = BuildDataField(prefixPath);
                _column.DataField = propertyString ?? string.Empty;
                QFDataGridCol col = _column as QFDataGridCol;

                if (col != null)
                {
                    col.IsSortable = !string.IsNullOrEmpty(propertyString);
                }
            }
            else
            {
                _column.DataField = string.Empty;
            }

            string caption;

            if (_component.TryGetPropertyValue("Caption", out caption) && !string.IsNullOrEmpty(caption))
            {
                _column.ColumnHeading = caption;
            }

            OnBuild();
        }