public static ServiceModel NewModel(Type compositeType, Visibility visibility, MetaInfo metaInfo, IEnumerable<Type> assemblyConcerns, IEnumerable<Type> sideEffects, IList<Type> mixins, String moduleName, String identity, bool instantiateOnStartup) { PropertyDeclarations propertyDeclarations = new MetaInfoDeclaration(); var constraintsModel = new ConstraintsModel(compositeType); bool immutable = metaInfo.Get<ImmutableAttribute>() != null; var propertiesModel = new ServicePropertiesModel(constraintsModel, propertyDeclarations, immutable); var stateModel = new ServiceStateModel(propertiesModel); var mixinsModel = new MixinsModel(compositeType, mixins); var concerns = new List<ConcernDeclaration>(); ConcernsDeclaration.ConcernDeclarations(assemblyConcerns, concerns); ConcernsDeclaration.ConcernDeclarations(compositeType, concerns); var concernsModel = new ConcernsDeclaration(concerns); var sideEffectsModel = new SideEffectsDeclaration(compositeType, sideEffects); var compositeMethodsModel = new CompositeMethodsModel(compositeType, constraintsModel, concernsModel, sideEffectsModel, mixinsModel); stateModel.AddStateFor(compositeMethodsModel.Properties, compositeType); return new ServiceModel( compositeType, visibility, metaInfo, mixinsModel, stateModel, compositeMethodsModel, moduleName, identity, instantiateOnStartup); }
private ServiceModel(Type compositeType, Visibility visibility, MetaInfo metaInfo, AbstractMixinsModel mixinsModel, AbstractStateModel stateModel, CompositeMethodsModel compositeMethodsModel, string moduleName, string identity, bool instantiateOnStartup) : base(compositeType, visibility, metaInfo, mixinsModel, stateModel, compositeMethodsModel) { this.moduleName = moduleName; this.identity = identity; this.instantiateOnStartup = instantiateOnStartup; }
private static void RefreshWAPLocalBranchProductHtml(long productId, string htmlUrl, string targetFilename, long branchId) { lock (htmlUrl) { if (System.IO.File.Exists(targetFilename) && !ProductManagerApplication.CheckNeedRefreshFile(System.IO.File.GetLastWriteTime(targetFilename), 20)) { return; } if (!HimallIO.ExistFile(htmlUrl)) { ProductManagerApplication.CreatBrandchWAPHtml(productId, branchId); } else { MetaInfo local_0 = HimallIO.GetFileMetaInfo(htmlUrl); if (local_0 == null || ProductManagerApplication.CheckNeedRefreshFile(local_0.LastModifiedTime, 60)) { ProductManagerApplication.CreatBrandchWAPHtml(productId, branchId); } } string local_1 = IOHelper.GetMapPath("/Storage/Products/Statics"); if (!Directory.Exists(local_1)) { Directory.CreateDirectory(local_1); } HimallIO.GetFileContent(htmlUrl); System.IO.File.WriteAllBytes(targetFilename, HimallIO.GetFileContent(htmlUrl)); } }
private LayerModel(string name, MetaInfo metaInfo, List<LayerModel> usedLayers, List<ModuleModel> modules) { this.Name = name; this.MetaInfo = metaInfo; this.usedLayers = usedLayers; this.modules = modules; }
/// <summary> /// 更新模版文件 /// </summary> public static void DownloadTemplate(string client, VTemplateClientTypes type, long shopId = 0) { var templatePath = GetTemplatePath(client, type, shopId); if (type == VTemplateClientTypes.SellerWapSpecial || type == VTemplateClientTypes.WapSpecial) { if (!Directory.Exists(HttpContext.Current.Server.MapPath(templatePath))) { var emptyTemplate = GetTemplatePath("0", type); CopyFolder(HttpContext.Current.Server.MapPath(emptyTemplate), HttpContext.Current.Server.MapPath(templatePath)); } } string datapath = templatePath + "data/default.json"; string cshtmlpath = templatePath + "Skin-HomePage.cshtml"; MetaInfo metaRemoteInfo = null; if (Core.HimallIO.IsNeedRefreshFile(datapath, out metaRemoteInfo)) { var metaLocalFile = GetFileMetaInfo(datapath); if (CheckMetaInfo(metaRemoteInfo, metaLocalFile)) { var dataFileBytes = Core.HimallIO.DownloadTemplateFile(datapath); if (null != dataFileBytes) { var strDataContent = Encoding.UTF8.GetString(dataFileBytes); string abDataPath = HttpContext.Current.Server.MapPath(datapath); using (StreamWriter sw = new StreamWriter(abDataPath, false, Encoding.UTF8)) { foreach (var s in strDataContent) { sw.Write(s); } } } } } if (Core.HimallIO.IsNeedRefreshFile(cshtmlpath, out metaRemoteInfo)) { var metaLocalFile = GetFileMetaInfo(cshtmlpath); if (CheckMetaInfo(metaRemoteInfo, metaLocalFile)) { var cshtmlFileBytes = Core.HimallIO.DownloadTemplateFile(cshtmlpath); if (null != cshtmlFileBytes) { var strCshtmlContent = Encoding.UTF8.GetString(cshtmlFileBytes); string abCshtmlPath = HttpContext.Current.Server.MapPath(cshtmlpath); using (StreamWriter sw = new StreamWriter(abCshtmlPath, false, Encoding.UTF8)) { foreach (var s in strCshtmlContent) { sw.Write(s); } } } } } }
private void UpgradeAltar_SettingReference(object sender, SettingReferenceEventArgs e) { pcMetaInfo = e.PC.GetComponent <MetaInfo>(); SetAltarPositions(); SetMaximums(); }
[TestMethod] public void Attribute() { Assert.AreEqual(MetaInfo.GetAttribute(typeof(Element), "subject1"), "e1"); Assert.AreEqual(MetaInfo.GetAttribute(typeof(Element), "property1", "subject1"), "ep1"); Assert.AreEqual(MetaInfo.GetAttributeDefault(typeof(Element), "property1", "subject1", "def"), "ep1"); Assert.AreEqual(MetaInfo.GetAttributeDefault(typeof(Element), "property1", "subject2", "def"), "def"); Assert.AreEqual(MetaInfo.GetAttribute(typeof(Element), "property1", "subject2"), null); }
private void Canvas_World_SettingReference(object sender, SettingReferenceEventArgs e) { skillManager = e.PC.GetComponent <PCSkillManager>(); pcLocalManager = e.PC.GetComponent <LocalManager>(); aimMetaInfo = e.AimMarker.GetComponent <MetaInfo>(); examineMetaInfo = e.ExamineMarker.GetComponent <MetaInfo>(); }
private static void AddGpsAlmsAndEphemerisTypes(MetaInfo metaInfo) { AddCustomTypeFromStdMessage(metaInfo, "GPSAlm", true); AddCustomTypeFromStdMessage(metaInfo, "GPSEphemeris", true); AddCustomTypeFromStdMessage(metaInfo, "IonoParams", false); AddCustomTypeFromStdMessage(metaInfo, "GpsNavData", false); AddCustomTypeFromStdMessage(metaInfo, "GpsRawNavData", false); }
private static bool CheckMetaInfo(MetaInfo remote, MetaInfo local) { if (null == remote) { return(false); } return((local != null) ? (remote.LastModifiedTime > local.LastModifiedTime) : true); }
public IPropertyAccessor <T> this[string propertyName] { get { int i = MetaInfo.IndexOf(propertyName); return(i > -1 ? _pAccessors[i] : null); } }
public override Mode Match(string[] objs, ref MetaInfo meta, bool partial = true) { if (meta == null) { throw new ArgumentNullException(nameof(meta)); } var res = new Mode().SetName(Name); var left = objs.Length - meta.Count; if (left == 0) { return(_atleast == 0 ? res : null); } meta.Branch(); Mode r; int idx = 0; if (_atmost > 0) { while (true) { if (idx >= _atmost) { break; } r = base.Match(objs, ref meta, true); if (r == null) { break; } res.AddRange(r); ++idx; } } else { while (true) { r = base.Match(objs, ref meta, true); if (r == null) { break; } res.AddRange(r); ++idx; } } #if DEBUG Console.WriteLine($"{name} <= {res.Dump()}"); #endif if (idx < _atleast) { meta.Rollback(); return(null); } meta.Pull(); return(res); }
private static void GenerateCppCode(string metaFile, string targetDir) { Logger.Instance.Info("Generating C++ code..."); var metaInfo = MetaInfo.FromXmlFile(metaFile); var cppGen = new CppCodeGenerator(metaInfo); cppGen.Generate(targetDir); Logger.Instance.Info("Done into {0}", targetDir); }
public MetaInfo GetDirMetaInfo(string dirName) { var path = GetPhysicalPath(dirName); MetaInfo info = new MetaInfo(); info.LastModifiedTime = Directory.GetLastWriteTime(path); info.ContentLength = Core.Helper.IOHelper.GetDirectoryLength(path); return(info); }
public CustomTypeNameFactory(MetaInfo metaInfo, Func <StandardMessage, string> stdMessageNameCustomizer = null, Func <CustomType, string> customTypeNameCustomizer = null) { this.customTypeNameCustomizer = customTypeNameCustomizer; this.stdMessageNameCustomizer = stdMessageNameCustomizer; this.customTypes = metaInfo.StandardMessages.Concat(metaInfo.CustomTypes); this.CreateTableNameCache(); }
public DicomFile LoadDicomFile(LoadSopDicomFileArgs args) { if (args.ForceCompleteHeader) { LoadFullHeader(args.IncludePixelData); } return(new DicomFile(null, MetaInfo.Copy(), DataSet.Copy())); }
private static int GetEnumInt(MetaName type, string enumString, StructureEntryDataType dataType) { var infos = MetaInfo.GetEnumInfo(type); if (infos == null) { return(0); } bool isFlags = (dataType == StructureEntryDataType.IntFlags1) || (dataType == StructureEntryDataType.IntFlags2);// || //(dataType == StructureEntryDataType.ShortFlags); if (isFlags) { //flags enum. (multiple values, comma-separated) var split = enumString.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); int enumVal = 0; for (int i = 0; i < split.Length; i++) { var enumName = GetHash(split[i].Trim()); for (int j = 0; j < infos.Entries.Count; j++) { var entry = infos.Entries[j]; if ((MetaName)entry.EntryNameHash == enumName) { enumVal += (1 << entry.EntryValue); break; } } } return(enumVal); } else { //single value enum. var enumName = (MetaName)GetHash(enumString); for (int j = 0; j < infos.Entries.Count; j++) { var entry = infos.Entries[j]; if ((MetaName)entry.EntryNameHash == enumName) { return(entry.EntryValue); } } } return(0); }
public DicomFile GetHeader(bool forceComplete) { if (forceComplete) { LoadFullHeader(); //Make sure the full header's loaded. } //Return a copy of whatever we've got. return(new DicomFile(null, MetaInfo.Copy(), DataSet.Copy())); }
public MySqlBaselineGenerator(MetaInfo metaInfo, string databaseName) { this.metaInfo = metaInfo; this.databaseName = databaseName; this.templateFilename = Path.Combine(PathHelper.StartupPath, "Templates/Sql/baselineTemplate.sql"); this.tableNames = new SqlTableNameFactory(this.metaInfo); }
public static Section ReadSection(string sourceFile, DataBuilder builder = null, string DefaultBuilderPassword = "******") { if (builder == null) { builder = new XorBuilder(); ((XorBuilder)builder).Key = Database.CurrentDatabase.TextEncoding.GetBytes(DefaultBuilderPassword); } Section section; int size; using (BinaryReader reader = new BinaryReader(File.Open(sourceFile, FileMode.Open))) { //READING METAINFO byte section_version = reader.ReadByte(); if (section_version != DB_SECTION_VERSION) { throw new Exception("Секция повреждена или недоступна!"); } size = reader.ReadInt32(); byte[] metadata = reader.ReadBytes(size); MetaInfo info = MetaInfo.ReadFrom(builder.Decode(metadata)); section = new Section(info.Address, info.Label, builder); int sz; byte[] data; while (reader.PeekChar() > -1) { byte objectId = reader.ReadByte(); ObjectDB obj = (ObjectDB)Activator.CreateInstance(ObjectDB.RestoreObject(objectId)); int ox = reader.ReadInt32(); int oy = reader.ReadInt32(); sz = reader.ReadInt32(); data = builder.Decode(reader.ReadBytes(sz)); obj.Label = Database.CurrentDatabase.TextEncoding.GetString(data); sz = reader.ReadInt32(); data = builder.Decode(reader.ReadBytes(sz)); obj.Content = data; section.Set(obj, new Position(ox, oy)); } } section.Builder = builder; return(section); }
public void FileNotInIndex() { var metaInfo = new MetaInfo(new FakeIQuery(), new AppSettings(), new FakeSelectorStorage(), null); var test = metaInfo.GetInfo(new List <string> { "/test" }, false); Assert.AreEqual(test.FirstOrDefault().Status, FileIndexItem.ExifStatus.NotFoundNotInIndex); }
/// <summary> /// 添加需要映射的属性成员。 /// </summary> /// <param name="propertyInfo"></param> /// <returns></returns> public ObjectAccessor <T> AppendProperty(IMetaPropertyInfo propertyInfo) { if (propertyInfo == null) { throw new ArgumentNullException("propertyInfo"); } MetaInfo.AddPropertyInfo(propertyInfo); return(this); }
public ReceiptForm(MetaInfo metaInfo, Person p) { InitializeComponent(); _metaInfo = metaInfo; _source = new BindingSource(); _receiptCollection = p.Receipts; _source.DataSource = _receiptCollection; _selectedReceipt = (Receipt)_source[0]; TableHelper.SetupReceiptTable(dataGridViewReceipt, _source); }
public bool RepeatCheck(int metaCode, int type) { MetaInfo metaInfo = meta.FindByPK(metaCode, type); if (metaInfo != null) { return(false); } return(true); }
private static void GenerateSqlBaseline(string metaFile, string targetDir, string databaseName) { Logger.Instance.Info("Generating sql baseline file..."); var metaInfo = MetaInfo.FromXmlFile(metaFile); var generator = new MySqlBaselineGenerator(metaInfo, databaseName); var fileName = Path.Combine(targetDir, DefaultSqlFileName); generator.Generate(fileName); Logger.Instance.Info("Done into {0}", fileName); }
public static void AddEnumAndStructureInfo(MetaBuilder mb) { var enumInfos = MetaInfo.GetStructureEnumInfo(MUnk_3538495220._MetaName); for (int i = 0; i < enumInfos.Length; i++) mb.AddEnumInfo((MetaName) enumInfos[i].EnumNameHash); mb.AddStructureInfo(MUnk_3538495220._MetaName); mb.AddStructureInfo((MetaName) (1535046754)); }
public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context) { var root = await context.Document.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false); var title = MetaInfo.ToLocalizableResourceStrings().CodeFix; context.Diagnostics .Where(d => d.Id == Id) .ForEach(d => RegisterCodeFix(title, context, root, d)); }
public BadMessage( string kind, string timeStamp, string message, MetaInfo meta ) : base(kind, timeStamp) { this.messageRaw = message; this.metaInfo = meta; }
public APICall() : base() { OperationFeatures.Add("EmptyBlock", 0); OperationFeatures.Add("RecoverFlag", 0); OperationFeatures.Add("OtherOperation", 0); MetaInfo.Add("RecoverFlag", null); MetaInfo.Add("OtherOperation", null); MetaInfo.Add("CheckIfBlock", null); MetaKeys = MetaInfo.Keys.ToList(); }
public static void AddEnumAndStructureInfo(MetaBuilder mb) { var enumInfos = MetaInfo.GetStructureEnumInfo(MCBaseArchetypeDef._MetaName); for (int i = 0; i < enumInfos.Length; i++) { mb.AddEnumInfo((MetaName)enumInfos[i].EnumNameHash); } mb.AddStructureInfo(MCBaseArchetypeDef._MetaName); }
public static void DownloadTemplate(string client, VTemplateClientTypes type, long shopId = 0L) { MetaInfo fileMetaInfo; StreamWriter writer; string path = GetTemplatePath(client, type, shopId); if (((type == VTemplateClientTypes.SellerWapSpecial) || (type == VTemplateClientTypes.WapSpecial)) && !Directory.Exists(HttpContext.Current.Server.MapPath(path))) { string str2 = GetTemplatePath("0", type, 0L); CopyFolder(HttpContext.Current.Server.MapPath(str2), HttpContext.Current.Server.MapPath(path)); } string fileName = path + "data/default.json"; string str4 = path + "Skin-HomePage.cshtml"; MetaInfo metaInfo = null; if (HimallIO.IsNeedRefreshFile(fileName, out metaInfo)) { fileMetaInfo = GetFileMetaInfo(fileName); if (CheckMetaInfo(metaInfo, fileMetaInfo)) { byte[] bytes = HimallIO.DownloadTemplateFile(fileName); if (null != bytes) { string str5 = Encoding.UTF8.GetString(bytes); using (writer = new StreamWriter(HttpContext.Current.Server.MapPath(fileName), false, Encoding.UTF8)) { foreach (char ch in str5) { writer.Write(ch); } } } } } if (HimallIO.IsNeedRefreshFile(str4, out metaInfo)) { fileMetaInfo = GetFileMetaInfo(str4); if (CheckMetaInfo(metaInfo, fileMetaInfo)) { byte[] buffer2 = HimallIO.DownloadTemplateFile(str4); if (null != buffer2) { string str7 = Encoding.UTF8.GetString(buffer2); using (writer = new StreamWriter(HttpContext.Current.Server.MapPath(str4), false, Encoding.UTF8)) { foreach (char ch in str7) { writer.Write(ch); } } } } } }
public static void AddEnumAndStructureInfo(MetaBuilder mb) { var enumInfos = MetaInfo.GetStructureEnumInfo(MUnk_1036962405._MetaName); for (int i = 0; i < enumInfos.Length; i++) { mb.AddEnumInfo((MetaName)enumInfos[i].EnumNameHash); } mb.AddStructureInfo(MUnk_1036962405._MetaName); }
public static void AddEnumAndStructureInfo(MetaBuilder mb) { var enumInfos = MetaInfo.GetStructureEnumInfo(Mrage__fwGrassInstanceListDef__InstanceData._MetaName); for (int i = 0; i < enumInfos.Length; i++) { mb.AddEnumInfo((MetaName)enumInfos[i].EnumNameHash); } mb.AddStructureInfo(Mrage__fwGrassInstanceListDef__InstanceData._MetaName); }
public ImportedServiceModel(Type serviceType, Visibility visibility, Type serviceImporter, string identity, MetaInfo metaInfo, string moduleName) { this.Type = serviceType; this.Visibility = visibility; this.ServiceImporter = serviceImporter; this.Identity = identity; this.MetaInfo = metaInfo; this.ModuleName = moduleName; }
protected AbstractCompositeModel(Type compositeType, Visibility visibility, MetaInfo metaInfo, AbstractMixinsModel mixinsModel, AbstractStateModel stateModel, CompositeMethodsModel compositeMethodsModel) { this.compositeType = compositeType; this.visibility = visibility; this.metaInfo = metaInfo; this.stateModel = stateModel; // Create proxy class this.proxyType = CreateProxyType(compositeType); this.mixinsModel = mixinsModel; this.compositeMethodsModel = compositeMethodsModel; }
private void Upsert(int index, uint flag, UString rubyText = null) { MetaInfo existing; if (!_metaInfos.TryGetValue(index, out existing)) { existing = new MetaInfo(); _metaInfos.Add(index, existing); } existing.Flags |= flag; if (flag == MetaInfo.RUBY_START) { if (rubyText == null) { throw new ArgumentNullException("rubyText"); } existing.RubyText = rubyText; } }
public ModuleModel(string name, MetaInfo metaInfo, TransientsModel transientsModel, EntitiesModel entitiesModel, ObjectsModel objectsModel, ValuesModel valuesModel, ServicesModel servicesModel, ImportedServicesModel importedServicesModel) { this.Name = name; this.MetaInfo = metaInfo; this.Transients = transientsModel; this.entities = entitiesModel; this.Objects = objectsModel; this.Values = valuesModel; this.Services = servicesModel; this.ImportedServicesModel = importedServicesModel; this.layerModel = null; }
public static ValueModel NewModel(Type compositeType, Visibility visibility, MetaInfo metaInfo, PropertyDeclarations propertyDeclarations, List<Type> assemblyConcerns, List<Type> sideEffects, List<Type> mixins) { var constraintsModel = new ConstraintsModel(compositeType); bool immutable = metaInfo.Get<ImmutableAttribute>() != null; var propertiesModel = new ValuePropertiesModel(constraintsModel, propertyDeclarations, immutable); var stateModel = new ValueStateModel(propertiesModel); var mixinsModel = new MixinsModel(compositeType, mixins); var concerns = new List<ConcernDeclaration>(); ConcernsDeclaration.ConcernDeclarations(assemblyConcerns, concerns); ConcernsDeclaration.ConcernDeclarations(compositeType, concerns); var concernsModel = new ConcernsDeclaration(concerns); var sideEffectsModel = new SideEffectsDeclaration(compositeType, sideEffects); var compositeMethodsModel = new CompositeMethodsModel(compositeType, constraintsModel, concernsModel, sideEffectsModel, mixinsModel); stateModel.AddStateFor(compositeMethodsModel.Properties, compositeType); return new ValueModel(compositeType, visibility, metaInfo, mixinsModel, stateModel, compositeMethodsModel); }
public void AddControl(Control oneControl) { // Obtain the initial metadata. MetaInfo one = new MetaInfo(oneControl); base.Controls.Add(oneControl); one.CharIndex = this.TextLength; one.TheControl.Location = this.GetPositionFromCharIndex(one.CharIndex); one.DeltaY = this.GetPositionFromCharIndex(0).Y - one.TheControl.Location.Y; ControlList.Add(one); //"Push" the text away from the space occupied by the control. do { this.AppendText(Environment.NewLine); } while (this.GetPositionFromCharIndex(this.TextLength).Y < (oneControl.Location.Y + oneControl.Height)); RemoveSome(); AutoScroll(); }
public ModuleAssemblyImpl(LayerAssembly layerAssembly, string name, MetaInfo metaInfo) { this.layerAssembly = layerAssembly; this.name = name; this.metaInfo = metaInfo; }
public void CreateMetaInfo() { BuildMeta = new MetaInfo(0); // find the build number based on main git repo and all its sub modules int buildnumber = 0; string GitFolder = CombinePaths(DLCDir, GIT_FOLDER_NAME); if (DirectoryExists(GitFolder)) { using (var repo = new LibGit2Sharp.Repository(GitFolder)) { MetaGitInfo gitinfo = new MetaGitInfo(); gitinfo.Name = "."; gitinfo.CommitCount = repo.Commits.Count(); gitinfo.SHA = repo.Commits.First().Id.ToString(); gitinfo.SHAShort = repo.Commits.First().Id.ToString(7); buildnumber += gitinfo.CommitCount; BuildMeta.CodeRepo = gitinfo; foreach (var submodule in repo.Submodules) { string SubFolder = CombinePaths(DLCDir, submodule.Path); if (DirectoryExists(SubFolder)) { using (var subrepo = new LibGit2Sharp.Repository(SubFolder)) { MetaGitInfo subgitinfo = new MetaGitInfo(); subgitinfo.Name = submodule.Name; subgitinfo.CommitCount = subrepo.Commits.Count(); subgitinfo.SHA = submodule.HeadCommitId.ToString(); subgitinfo.SHAShort = submodule.HeadCommitId.ToString(7); buildnumber += subgitinfo.CommitCount; BuildMeta.SubRepos.Add(subgitinfo); } } } } } BuildMeta.BuildNumber = buildnumber; }
public PCCPackage(DLCPackage dlc, int Index, bool loadfull = true, bool verbosemode = false) { try { verbose = verbosemode; MemoryStream m = dlc.DecompressEntry(Index); GeneralInfo = new MetaInfo(); GeneralInfo.inDLC = true; GeneralInfo.loadfull = loadfull; GeneralInfo.filepath = dlc.MyFileName; GeneralInfo.inDLCPath = dlc.Files[Index].FileName; GeneralInfo.dlc = dlc; GeneralInfo.inDLCIndex = Index; Load(m); GeneralInfo.loaded = true; } catch (Exception ex) { DebugLog.PrintLn("PCCPACKAGE::PCCPACKAGE ERROR:\n" + ex.Message); } }
public void FromXmlBase(ref XElement res, string directoryName) { //var xmlSerializer = new XmlSerializer(typeof (PoI)); //var p = xmlSerializer.Deserialize(res.CreateReader()); try { Id = res.GetGuid("Id"); if (Id == Guid.Empty) Id = Guid.NewGuid(); var n = res.GetString("Name"); ContentId = res.GetString("PoiId", ""); if (String.IsNullOrEmpty(ContentId)) ContentId = n; Priority = res.GetInt("Priority", 2); UserId = res.GetString("UserId"); DateLong = res.GetLong("Date", DateTime.Now.ToEpoch()); UpdatedLong = res.GetLong("Updated", DateTime.Now.ToEpoch()); Layer = res.GetString("Layer"); MaxItems = res.GetNullInt("MaxItems"); var xMid = res.Element("MetaInfoData"); PoiTypeId = res.GetString("PoiTypeId", ""); IsVisibleInMenu = res.GetBool("IsVisibleInMenu", true); Orientation = res.GetDouble("Orientation", 0.0); //if (!string.IsNullOrEmpty(PoiTypeId)) //{ //} if (xMid != null) { var metaInfo = new MetaInfoCollection(); foreach (var xMi in xMid.Elements()) { var mi = new MetaInfo(); mi.FromXml(xMi); metaInfo.Add(mi); } MetaInfo = metaInfo; } if (res.Element("WKT") != null) { var xElement = res.Element("WKT"); if (xElement != null) WktText = xElement.Value; } var xlabels = res.Element("Labels"); if (xlabels != null) { Labels = new Dictionary<string, string>(); foreach (var xk in xlabels.Elements()) { var k = xk.Name.LocalName; // Restore keys starting with numbers or having % or '. k = k.Replace(LabelPercentSubst, "%"); k = k.Replace(LabelQuoteSubst, "'"); if (k.StartsWith(LabelNumPrefix)) { k = k.Substring(LabelNumPrefix.Length); } var s = xk.InnerXml(); Labels[k] = s.RestoreInvalidCharacters(); Labels[k] = Labels[k].Replace("<", "<").Replace(">", ">"); } } var xkeywords = res.Element("Keywords"); if (xkeywords != null) { Keywords = new WordHistogram(); Keywords.FromXml(xkeywords); } if (res.Element("Style") != null) { try { var newStyle = new PoIStyle(); newStyle.FromXml(res.Element("Style"), directoryName, false); //, Service.Settings); // TODO REVIEW: Settings were ignored. Style = newStyle; } catch (Exception) { // OK, keep the old style. } } var media = res.Element("AllMedia"); if (media != null) { AllMedia = new BindableCollection<Media>(); foreach (var m in media.Elements()) { var me = new Media { Content = this }; me.FromXml(m); AllMedia.Add(me); } } var xpos = res.Element("Position"); if (xpos != null) Position = new Position(xpos.GetDouble(Position.LONG_LABEL), xpos.GetDouble(Position.LAT_LABEL), xpos.GetDouble(Position.ALT_LABEL)); // TODO Remember other Position attributes. var px = res.Element("Points"); var mo = res.Element("Models"); if (mo != null) { Models = new List<Model>(); foreach (var xm in mo.Elements()) { var m = new Model(); m.FromXml(xm); Models.Add(m); } } if (px == null) return; var pp = px.Value; Points = new ObservableCollection<Point>(); var ppo = pp.Split(' '); foreach (var poss in ppo) { var split = poss.Split(','); var pt = new Point( Double.Parse(split[0], CultureInfo.InvariantCulture), Double.Parse(split[1], CultureInfo.InvariantCulture)); Points.Add(pt); } } catch (SystemException e) { Logger.Log("DataServer.BaseContent", "Error reading XML " + res + " from " + directoryName, e.Message, Logger.Level.Error, true); } }
public PCCPackage() { GeneralInfo = new MetaInfo(); GeneralInfo.loaded = false; }
public PCCPackage(string pccpath, bool loadfull = true, bool verbosemode = false, bool closestream = false) { try { verbose = verbosemode; FileStream fs = new FileStream(pccpath, FileMode.Open, FileAccess.ReadWrite); GeneralInfo = new MetaInfo(); GeneralInfo.loadfull = loadfull; GeneralInfo.filepath = pccpath; Load(fs); GeneralInfo.loaded = true; if(closestream) fs.Close(); } catch (Exception ex) { DebugLog.PrintLn("PCCPACKAGE::PCCPACKAGE ERROR:\n" + ex.Message); } }
public void TypeFromGeoJson(JProperty json) { MetaInfo = new MetaInfoCollection(); foreach (var childJ in json.Children().OfType<JObject>()) { JToken tokenS; childJ.TryGetValue("style", out tokenS); if (tokenS != null) { // First, convert the JSON to XML. var styleNode = JsonConvert.DeserializeXmlNode("{style:" + tokenS + "}"); var styleDoc = styleNode.ToXDocument(); var xElement = styleDoc.Element(XName.Get("style")); if (xElement != null) { // Convert child nodes to attributes. foreach (var el in xElement.Elements()) { xElement.Add(new XAttribute(UppercaseFirst(el.Name), (string)el)); } xElement.Elements().Remove(); // Parse the style. try { var newStyle = new PoIStyle(); newStyle.FromXml(xElement, ".", false); // Do not catch exception. Style = newStyle; } catch { // Ok, keep old style. } } } JToken tokenM; childJ.TryGetValue("propertyTypeData", out tokenM); if (tokenM != null) { var metaInfos = tokenM.Children(); foreach (var metaInfo in metaInfos) { var newMetaInfo = new MetaInfo(); newMetaInfo.FromGeoJson(metaInfo.ToString(Formatting.None), false); MetaInfo.Add(newMetaInfo); } } } }
public EntityModel(Type compositeType, Visibility visibility, MetaInfo metaInfo, AbstractMixinsModel mixinsModel, AbstractStateModel stateModel, CompositeMethodsModel compositeMethodsModel) : base(compositeType, visibility, metaInfo, mixinsModel, stateModel, compositeMethodsModel) { }
public override void Subscribe(Mode serviceMode) { base.Subscribe(serviceMode); Reset(); PoIs.StartBatch(); //var isLoaded = LoadOrCreateDataServiceDescription(saveDsd); IsLoading = true; try { var layer = api.layers.GetLayer(this.csLayer.Id); if (layer.TypeUrl.Length > 0) layer.TypeUrl = layer.TypeUrl.TrimStart('/'); this.IsTimelineEnabled = true; if (!string.IsNullOrEmpty(layer.TypeUrl)) { if (layer.TypeUrl.StartsWith("api/resources/") || layer.TypeUrl.StartsWith("data/resourceTypes/")) { var r = layer.TypeUrl.Replace("api/resources/", ""); r = r.Replace("data/resourceTypes/", ""); r = r.Replace(".json", ""); var template = this.dsb.Templates.FirstOrDefault(t => t.Name == r); if (template == null) { resource = api.resources.GetResource(r); // var ps = new PoiService(); // ps.Name = r; // ps.IsTemplate = true; // ps.InitPoiService(); //dsb.Templates.Add(ps); foreach (var ft in resource.FeatureTypes) { var st = ft.Value.Style; var p = new global::DataServer.PoI { ContentId = ft.Key, PoiId = ft.Key, Service = this, Id = Guid.NewGuid(), Style = new PoIStyle { DrawingMode = DrawingModes.Point, Icon = AppState.Config.Get("csWebApiServer", "http://localhost:3002") + "/" + ft.Value.Style.IconUri, //Picture = new BitmapImage(new Uri("http://localhost:3002/" + ft.Value.Style.IconUri))m CallOutFillColor = Colors.LightBlue, CallOutForeground = Colors.Black, CallOutTimeOut = 10, CallOutOrientation = CallOutOrientation.RightSideMenu, FillOpacity= ft.Value.Style.FillOpacity, StrokeColor= (Color)ColorConverter.ConvertFromString(ft.Value.Style.StrokeColor), StrokeOpacity = ft.Value.Style.Opacity, }, MetaInfo = new List<MetaInfo>() }; if (ft.Value.Style.FillColor != null) { p.Style.FillColor = (Color) ColorConverter.ConvertFromString(ft.Value.Style.FillColor); } if (ft.Value.Style.StrokeColor != null) { p.Style.StrokeColor = (Color)ColorConverter.ConvertFromString(ft.Value.Style.StrokeColor); } if (!string.IsNullOrWhiteSpace(p.Style.Icon)) { p.Style.Picture = new BitmapImage(p.Style.IconUri); } if (!string.IsNullOrEmpty(st.NameLabel)) p.Style.NameLabel = st.NameLabel; if (ft.Value.PropertyTypeKeys != null) { var properties = ft.Value.PropertyTypeKeys.Split(';'); if (properties.Length > 0) { foreach (var prop in properties) { if (resource.PropertyTypeData.ContainsKey(prop)) { var rp = resource.PropertyTypeData[prop]; var mi = new MetaInfo() { Label = rp.Label, Description = rp.Description, VisibleInCallOut = true, IsSearchable = true, Section = rp.Section, IsEditable = rp.CanEdit ?? true, Title = rp.Title }; switch (rp.Type.ToLower()) { case "string": mi.Type = MetaTypes.text; break; case "number": mi.Type = MetaTypes.number; break; case "date": mi.Type = MetaTypes.datetime; break; } p.MetaInfo.Add(mi); } } } } if (PoITypes.All(pt => pt.ContentId != p.ContentId)) this.PoITypes.Add(p); //ps.PoITypes.Add(p); } } } if (layer.TypeUrl.StartsWith(api.client.BasePath)) { //api.resources.GetResource() } } this.PoIs.CollectionChanged += (es, tp) => { if (tp.NewItems != null && IsInitialized) { foreach (global::DataServer.PoI p in tp.NewItems) { var newp = (!availablePoIs.Contains(p.Id.ToString())); if (newp) { if (IsInitialized) { var f = GetFeatureFromPoi(p); WebApiService.SyncPoi(p, layer, f, api); api.features.AddFeature(layer.Id, f); } availablePoIs.Add(p.Id.ToString()); } } // foreach (va) } }; sub = api.GetLayerSubscription(layer.Id); sub.LayerCallback += (e, s) => { Execute.OnUIThread(()=> { switch (s.action) { case LayerUpdateAction.deleteFeature: var dp = PoIs.FirstOrDefault( k => k.Data.ContainsKey("cs") && ((Feature)k.Data["cs"]).Id == s.featureId); if (dp != null) { RemovePoi(dp); } break; case LayerUpdateAction.updateFeature: var f = GetFeature((JObject)s.item); // find feature var p = PoIs.FirstOrDefault(k => k.Data.ContainsKey("cs") && ((Feature)k.Data["cs"]).Id == f.Id); if (p != null) { // update poi UpdateFeature(f, (global::DataServer.PoI)p, layer); //TriggerContentChanged(p); } else { // add poi var g = Guid.NewGuid(); availablePoIs.Add(g.ToString()); var np = AddFeature(f, g, layer); } break; } }); }; foreach (var f in layer.Features) { var p = AddFeature(f, Guid.NewGuid(), layer); availablePoIs.Add(p.Id.ToString()); } IsLoading = false; ContentLoaded = true; Execute.OnUIThread(() => Layer.IsLoading = false); PoIs.FinishBatch(); } catch (Exception e) { AppState.TriggerNotification(e.Message); } }
/// <summary> /// Convert the PoI to a GeoJSON string. /// </summary> /// <returns>GeoJSON string.</returns> public string ToGeoJson() { var builder = new StringBuilder("{\"type\":\"Feature\",\"geometry\": "); if (!string.IsNullOrEmpty(WktText)) { var wellKnownText = new WellKnownTextIO(WktText); var geoJson = wellKnownText.ToGeoJson(); // This will include {"type":"...","coordinates":[...]} if (!string.IsNullOrEmpty(geoJson)) { builder.Append(geoJson); } else { builder.Append(Position != null ? Position.ToGeoJson() : new Position(0, 0).ToGeoJson()); } } else { builder.Append(Position != null ? Position.ToGeoJson() : new Position(0, 0).ToGeoJson()); } if (HasKeywords) { builder.Append(",\"keywords\":"); builder.Append(Keywords.ToGeoJson()); } builder.Append(",\"properties\":{"); var first = true; foreach (var label in Labels) { var key = label.Key; var mi = EffectiveMetaInfo?.FirstOrDefault(m => string.Equals(m.Label, key)); var dealtWith = false; if (mi == null) mi = new MetaInfo { Type = MetaTypes.text }; switch (mi.Type) { case MetaTypes.number: double resultDouble; var isDouble = Double.TryParse(label.Value, out resultDouble); if (isDouble) { int resultInt; var isInt = Int32.TryParse(label.Value, out resultInt); if (isInt && Math.Abs(resultInt - resultDouble) < 0.000001) { if (!first) builder.Append(","); builder.AppendFormat("\"{0}\":{1}", key, resultInt); } else { if (!first) builder.Append(","); builder.AppendFormat("\"{0}\":{1}", key, resultDouble); } dealtWith = true; } if (!dealtWith) { var value = string.IsNullOrEmpty(label.Value) ? string.Empty : label.Value.Trim().RemoveInvalidCharacters(); if (!first) builder.Append(","); builder.AppendFormat("\"{0}\":\"{1}\"", key, value); // builder.AppendFormat("\"{0}\":\"{1}\"", key, label.Value.Trim().Replace('"', '\'').Replace(Environment.NewLine, string.Empty)); } break; case MetaTypes.options: if (!first) builder.Append(","); if (mi.Options == null) break; var index = mi.Options.IndexOf(label.Value); if (index < 0) builder.AppendFormat("\"{0}\":\"{1}\"", key, string.IsNullOrEmpty(label.Value) ? string.Empty : label.Value.Trim().RemoveInvalidCharacters()); else builder.AppendFormat("\"{0}\":{1}", key, index); break; default: if (!first) builder.Append(","); builder.AppendFormat("\"{0}\":\"{1}\"", key, string.IsNullOrEmpty(label.Value) ? string.Empty : label.Value.Trim().RemoveInvalidCharacters()); break; } first = false; } // EV Do not save the ID, not needed in the GeoJSON. //AppendPropertyToGeoJson(builder, GetType().GetProperty("Id"), Labels.Count > 0); // REVIEW I don't like having to hardcode the property names. //AppendPropertyToGeoJson(builder, GetType().GetProperty("Name")); // Otherwise, the name will be added twice, since it refers to a label if (Math.Abs(Orientation) > 0.0001) AppendPropertyToGeoJson(builder, GetType().GetProperty("Orientation")); if (!string.IsNullOrEmpty(ContentId)) AppendPropertyToGeoJson(builder, GetType().GetProperty("ContentId")); if (!string.IsNullOrEmpty(PoiTypeId)) AppendPropertyToGeoJson(builder, GetType().GetProperty("PoiTypeId")); if (!string.IsNullOrEmpty(Layer)) AppendPropertyToGeoJson(builder, GetType().GetProperty("Layer")); if (!DateTime.Equals(Date, DefaultDate)) AppendPropertyToGeoJson(builder, GetType().GetProperty("Date")); if (MaxItems != null && Math.Abs(MaxItems.Value) > 0.0001) AppendPropertyToGeoJson(builder, GetType().GetProperty("MaxItems")); builder.Append("}}"); return builder.ToString(); }
private ApplicationModel(string name, MetaInfo metaInfo, IList<LayerModel> layers) { this.Name = name; this.MetaInfo = metaInfo; this.layers = layers; }
/// <summary> /// Add meta info to the PoIType. /// </summary> /// <param name="title">Display title</param> /// <param name="source">Source label</param> /// <param name="type"></param> /// <param name="searchable"></param> /// <param name="visibleInCallout"></param> /// <param name="section"></param> /// <param name="options"></param> /// <param name="minvalue"></param> /// <param name="maxvalue"></param> /// <param name="format"></param> /// <param name="editActive"></param> /// <param name="canEdit"></param> public MetaInfo AddMetaInfo(string title, string source, MetaTypes type = MetaTypes.text, bool searchable = false, bool visibleInCallout = true, string section = "Info", List<string> options = null, double minvalue = Double.NaN, double maxvalue = Double.NaN, string format = null, bool editActive = false, bool canEdit = true) { var metaInfo = MetaInfo ?? new MetaInfoCollection(); var mi = new MetaInfo { Label = source, Title = title, Type = type, VisibleInCallOut = visibleInCallout, IsSearchable = searchable, Options = options, MinValue = minvalue, MaxValue = maxvalue, StringFormat = format, EditActive = editActive, IsEditable = canEdit }; if (!String.IsNullOrEmpty(section)) mi.Section = section; metaInfo.Add(mi); MetaInfo = metaInfo; return mi; }
MetaInfo Get (BaseAnimatorAccess component) { var key = GetKey (component); if (!entries.ContainsKey (key)) { string fileName = key + ".cs"; string backupFileName = key + ".txt"; string file = CodeGenerationUtils.GetPathToFile (fileName); string backupFile = CodeGenerationUtils.GetPathToFile (backupFileName, backupDir); string timestamp = ""; if (!string.IsNullOrEmpty (backupFile)) { timestamp += File.GetCreationTime (backupFile); } entries [key] = new MetaInfo (file, backupFile, timestamp); } return entries [key]; }
/// <summary> /// Makes the backup to backupDir and updates the corresponding MetaInfo. /// </summary> /// <param name="className">Class name.</param> /// <param name="file">File.</param> public void MakeBackup (string className, string file) { string backupFile = MakeBackup (file); string timestamp = "" + File.GetCreationTime (backupFile); entries [className] = new MetaInfo (file, backupFile, timestamp); }