public static string GetReflectedFullName(SqlTagContext ctx, BaseTag tag, string propertyName) { if (ctx == null) { throw new ArgumentNullException("ctx"); } if (tag == null) { throw new ArgumentNullException("tag"); } if (propertyName == null) { throw new ArgumentNullException("propertyName"); } var currentIteratorContext = ctx.GetAttribute(tag) as IterateContext; // is current tag an iterate? if (currentIteratorContext != null) { propertyName = String.Format("{0}[{1}]", propertyName, currentIteratorContext.Index); } var parentIteratorTag = FindParentIteratorTag(ctx, tag); // is current node a child of another iterate node? if (parentIteratorTag != null) { return(BuildReflectedFullName(ctx, parentIteratorTag, propertyName)); } return(propertyName); }
public static BaseContainer GetDataInstance(BaseTag op) { global::System.IntPtr cPtr = C4dApiPINVOKE.TagDataM_GetDataInstance__SWIG_0(BaseTag.getCPtr(op)); BaseContainer ret = (cPtr == global::System.IntPtr.Zero) ? null : new BaseContainer(cPtr, false); return(ret); }
/// <summary> /// Read swf (header and tags), this is the only /// public method of <see cref="SwfDotNet.IO.SwfReader">SwfReader</see> /// with <see cref="SwfDotNet.IO.SwfReader.Close">Close</see> and /// <see cref="SwfDotNet.IO.SwfReader.ReadSwfHeader">ReadSwfHeader</see> methods. /// The returned <see cref="SwfDotNet.IO.Swf">Swf</see> object contains swf headers informations and the /// tags list. /// </summary> public Swf ReadSwf() { // compressed swf? if (br.PeekChar() == 'C') { Inflate(); } SwfHeader header = new SwfHeader(); header.ReadData(br); this.version = header.Version; tagList = new BaseTagCollection(); bool readEndTag = false; //necessary for the 1 more byte bug while (br.BaseStream.Position < br.BaseStream.Length && !readEndTag) { BaseTag b = SwfReader.ReadTag(this.version, this.br, this.tagList); if (b != null) { if (b is EndTag) { readEndTag = true; } tagList.Add(b); } } ; br.Close(); return(new Swf(header, tagList)); }
/// <summary> /// Read swf (header and tags), this is the only public method of <see cref="SwfOp.IO.SwfReader">SwfReader</see> /// </summary> public Swf ReadSwf() { // compressed swf? if (br.PeekChar() == 'C') { inflate(); } SwfHeader header = ReadHeader(); this.version = header.Version; ArrayList tagList = new ArrayList(); try { streamEnd = br.BaseStream.Length; while (br.BaseStream.Position < streamEnd) { BaseTag b = this.ReadTag(); tagList.Add(b); } ; } catch (Exception eos) { Console.WriteLine("-- Error: Tag reader error: [" + eos.Message + "]"); } BaseTag[] tags = new BaseTag[tagList.Count]; tagList.CopyTo(tags, 0); br.Close(); return(new Swf(header, tags)); }
/// <summary> /// This class is responsible for getting the current iterate item object within an iteration. i.e. The property name starts with "[]." /// We do this by navigating up through the parent nodes to determine which of them are iterate elements. /// Once found we get the current iteration context item. /// If "[]." is not specified, the original approach is used of reflecting the parameterObject to the reflection path specified in the property /// </summary> /// <param name="ctx"></param> /// <param name="baseTag"></param> /// <param name="parameterObject"></param> /// <returns></returns> /// <remarks> /// Created By: Richard Beacroft /// Created Date: 11\10\2013 /// </remarks> protected object GetMemberPropertyValue(SqlTagContext ctx, BaseTag baseTag, object parameterObject) { if (String.IsNullOrEmpty(baseTag.Property)) { return(parameterObject); } #if dotnet35 var bindingReplacement = ctx.BuildPropertyBindingReplacements(baseTag).FirstOrDefault(); #else BindingReplacement bindingReplacement = null; foreach (var replacement in ctx.BuildPropertyBindingReplacements(baseTag)) { bindingReplacement = replacement; break; } #endif if (bindingReplacement != null) { if (String.IsNullOrEmpty(bindingReplacement.FullPropertyName)) { return(bindingReplacement.Value); } return(_tagPropertyProbe.GetMemberValue(ctx, baseTag, bindingReplacement.FullPropertyName, parameterObject)); } return(_tagPropertyProbe.GetMemberPropertyValue(ctx, baseTag, parameterObject)); }
/// <summary> /// Read swf (header and tags), this is the only public method of <see cref="SwfOp.IO.SwfReader">SwfReader</see> /// </summary> public Swf ReadSwf() { // compressed swf? if (br.PeekChar() == 'C') { inflate(); } SwfHeader header = ReadHeader(); this.version = header.Version; ArrayList tagList = new ArrayList(); while (br.BaseStream.Position < br.BaseStream.Length) { BaseTag b = this.ReadTag(); tagList.Add(b); } ; BaseTag[] tags = new BaseTag[tagList.Count]; tagList.CopyTo(tags, 0); br.Close(); return(new Swf(header, tags)); }
public VariableTag MakeVariableTag(int type, int count, BaseTag pred) { global::System.IntPtr cPtr = C4dApiPINVOKE.BaseObject_MakeVariableTag__SWIG_0(swigCPtr, type, count, BaseTag.getCPtr(pred)); VariableTag ret = (cPtr == global::System.IntPtr.Zero) ? null : new VariableTag(cPtr, false); return(ret); }
public BaseTag MakeTag(int type) { global::System.IntPtr cPtr = C4dApiPINVOKE.BaseObject_MakeTag__SWIG_1(swigCPtr, type); BaseTag ret = (BaseTag)C4dApiPINVOKE.InstantiateConcreteTag(cPtr, false); return(ret); }
public static SwfDecompiledMap ReadSwfMap(string id, string mapid) { string path = (Constants.MapsPath + $"{id}" + "_" + $"{mapid}X.swf"); SwfReader Reader = new SwfReader(path); Swf swf = Reader.ReadSwf(); SwfDecompiledMap mapDatas = null; IEnumerator enumerator = swf.Tags.GetEnumerator(); while (enumerator.MoveNext()) { BaseTag current = (BaseTag)enumerator.Current; if (current.ActionRecCount != 0) { string sb = ""; IEnumerator currentenumerator = current.GetEnumerator(); while (currentenumerator.MoveNext()) { Decompiler decompiler = new Decompiler(swf.Version); ArrayList actions = decompiler.Decompile((byte[])currentenumerator.Current); foreach (BaseAction obj in actions) { sb += obj.ToString(); } } mapDatas = ParseSwfMapDatas(sb); } } Reader.Close(); return(mapDatas); }
public new BaseTag GetPred() { global::System.IntPtr cPtr = C4dApiPINVOKE.BaseTag_GetPred(swigCPtr); BaseTag ret = (BaseTag)C4dApiPINVOKE.InstantiateConcreteTag(cPtr, false); return(ret); }
public BaseTag GetFirstTag() { global::System.IntPtr cPtr = C4dApiPINVOKE.BaseObject_GetFirstTag(swigCPtr); BaseTag ret = (BaseTag)C4dApiPINVOKE.InstantiateConcreteTag(cPtr, false); return(ret); }
private void setJointWeight(int tagPos, BaseObject op2, PointObject pObj) { BaseTag t = op2.GetTag(C4dApi.Tpointselection, tagPos); SelectionTag st = (SelectionTag)op2.GetTag(C4dApi.Tpolygonselection); BaseSelect SelectedPoints = st.GetBaseSelect(); if (t.GetName() == null) { } else { string selectioname = t.GetName(); for (int j = 0; j < this.wtagGlob.GetJointCount(); j++) { if (selectioname == this.wtagGlob.GetName()) { for (int i = 0; i < pObj.GetPointCount(); i++) { if (SelectedPoints.IsSelected(i)) { this.wtagGlob.SetWeight(1, i, 0.04); setJointWeight(tagPos + 1, op2, pObj); //C4dApi.GePrint("Der Punkt mit dem Index " + i + " ist selektiert"); } } } } } }
public new static BaseTag Alloc(int type) { global::System.IntPtr cPtr = C4dApiPINVOKE.BaseTag_Alloc(type); BaseTag ret = (BaseTag)C4dApiPINVOKE.InstantiateConcreteTag(cPtr, false); return(ret); }
public void MultiTagOptionsTest(string pattern, BaseTag expectedTag) { List <BaseTag> actualTags = PatternParser.Parse(pattern); Assert.AreEqual(1, actualTags.Count); Assert.AreEqual(expectedTag, actualTags[0]); }
public string GetBytesCode() { StringBuilder code = new StringBuilder(); SwfReader Reader = new SwfReader(this.File); Swf swf = null; try { swf = Reader.ReadSwf(); } catch (Exception Ex) { throw new Exception(Ex.ToString()); } IEnumerator enumerator = swf.Tags.GetEnumerator(); while (enumerator.MoveNext()) { BaseTag current = (BaseTag)enumerator.Current; if (current.ActionRecCount != 0) { IEnumerator currentenumerator = current.GetEnumerator(); while (currentenumerator.MoveNext()) { Decompiler decompiler = new Decompiler(swf.Version); foreach (BaseAction action in decompiler.Decompile((byte[])currentenumerator.Current)) { code.AppendLine(action.ToString()); } } } } return(code.ToString()); }
public BaseTag GetActiveTag() { global::System.IntPtr cPtr = C4dApiPINVOKE.BaseDrawHelp_GetActiveTag(swigCPtr); BaseTag ret = (BaseTag)C4dApiPINVOKE.InstantiateConcreteTag(cPtr, false); return(ret); }
public JsonResult GetFeeEstimateData(string ASIN) { try { StreamWriter BaseTag; var uploadRootFolder = AppDomain.CurrentDomain.BaseDirectory + "\\Reports"; Directory.CreateDirectory(uploadRootFolder); var directoryFullPath = uploadRootFolder; string targetFile = Path.Combine(directoryFullPath, "FeeEstimateResponse_" + Guid.NewGuid() + ".xml"); var response = InvokeGetMyFeesEstimate(ASIN); BaseTag = System.IO.File.CreateText(targetFile); BaseTag.Write(response.ToXML()); BaseTag.Close(); XmlDocument root = new XmlDocument(); root.Load(targetFile); XmlNodeList elemList1 = root.GetElementsByTagName("FeeAmount"); var data = elemList1[3].InnerText; var currency = data.Substring(0, 3); var fee = data.Substring(3); return(Json(new { result = true, currency = currency, fee = fee }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { result = false }, JsonRequestBehavior.AllowGet)); } }
/// <summary> /// Writes the (compressed or uncompressed) swf data to a stream. /// The stream gets flushed and closed afterwards. /// </summary> /// <param name="swf">Swf</param> public void Write(Swf swf) { if (swf == null) { return; } // add EndTag is is not the last one BaseTag lastTag = swf.Tags.GetLastOne(); if (lastTag == null || !(lastTag is EndTag)) { swf.Tags.Add(new EndTag()); } // update tag lengths to adapt to bytecode length swf.UpdateData(); SwfHeader header = swf.Header; // ASCII seems to be ok for Flash 5 and 6+ as well BufferedBinaryWriter writer = new BufferedBinaryWriter(baseStream, System.Text.Encoding.GetEncoding("ascii")); BufferedBinaryWriter dataWriter = writer; bool isCompressed = (header.Signature[0] == 'C'); if (isCompressed && swf.Version >= 6) { // SharpZipLib makes it easy for us, simply // chain a Deflater into the stream DeflaterOutputStream def = new DeflaterOutputStream(baseStream); dataWriter = new BufferedBinaryWriter(def); } // writer header data, always uncompressed writer.WriteString(header.Signature, 3); writer.Write(swf.Version); writer.Write(swf.ByteCount); writer.Flush(); // write header data pt.2, using either // original stream or deflater stream header.Size.WriteTo(dataWriter); dataWriter.SynchBits(); dataWriter.WriteFWord(header.Fps, 8, 8); dataWriter.Write(header.Frames); // write tags data IEnumerator tags = swf.Tags.GetEnumerator(); while (tags.MoveNext()) { BaseTag tagToWrite = (BaseTag)tags.Current; dataWriter.Write(tagToWrite.Data); } // flush + close dataWriter.Flush(); dataWriter.Close(); }
static void Main(string[] args) { BaseTag bt = new BaseTag(null); bt.Div().Id("teste").Div().Id("ee").Div().Close().Span().Close().Span().Div().Id("r").Close().Div().Id("id2"); Console.WriteLine(bt); Console.ReadKey(); }
internal IList <BindingReplacement> BuildPropertyBindingReplacements(BaseTag tag) { if (tag == null) { throw new ArgumentNullException("tag"); } return(InlineParameterMapParser.BuildBindingReplacements(_bindings, new StringBuilder(tag.Property))); }
private void AddTag(BaseTag tag) { var data = TagDataFactory.CreateTagData(tag); if (data != null) { cache.AddTagData(data); } }
public static void ReadSwfLang(string path) { //This part is dirty but there arent so much ressources about how to decompile langs, decompilation & reading takes more than12 secondes.. StringHelper.WriteLine($"[DataManager] Reading maps lang ..", ConsoleColor.Cyan); SwfReader Reader = new SwfReader(path); Swf swf = Reader.ReadSwf(); IEnumerator enumerator = swf.Tags.GetEnumerator(); while (enumerator.MoveNext()) { BaseTag current = (BaseTag)enumerator.Current; if (current.ActionRecCount != 0) { string sb = ""; IEnumerator currentenumerator = current.GetEnumerator(); while (currentenumerator.MoveNext()) { Decompiler decompiler = new Decompiler(swf.Version); ArrayList actions = decompiler.Decompile((byte[])currentenumerator.Current); foreach (BaseAction obj in actions) { sb += obj.ToString(); } //maps coords & subarea id string regex = @"getMemberpush ([0-9]*?) as int push (-?[0-9]*?) as var push (-?[0-9]*?) as int push (-?[0-9]*?) as var push (-?[0-9]*?) as int push (-?[0-9]*?) as var push (-?[0-9]*?) as int"; MatchCollection matches = Regex.Matches(sb, regex); foreach (Match match in matches) { GlobalMapsInfos.Add(new MapDatas(int.Parse(match.Groups[1].Value), int.Parse(match.Groups[3].Value), int.Parse(match.Groups[5].Value), int.Parse(match.Groups[7].Value))); } //area id foreach (var map in GlobalMapsInfos.Where(x => x.AreaId == -1)) { var regex2 = @"getMemberpush " + map.SubAreaId + " as int push (-?[0-9]*?) as var push (-?[0-9]*?) as var push (-?[0-9]*?) as var push (-?[0-9]*?) "; var matches2 = Regex.Matches(sb, regex2); foreach (Match match2 in matches2) { map.AreaId = int.Parse(match2.Groups[4].Value); } } GC.Collect(); GC.WaitForPendingFinalizers(); sb = ""; Console.Write($"\r{DateTime.Now:[HH:mm:ss:fff]} [DataManager] {GlobalMapsInfos.Count()} maps loaded.."); } } } Reader.Close(); swf = null; Console.Write("\n"); StringHelper.WriteLine($"[DataManager] {GlobalMapsInfos.Count()} maps added to list !", ConsoleColor.Cyan); StringHelper.WriteLine("[DataManager] Map with undefinied AreaId : " + GlobalMapsInfos.Count(x => x.AreaId == -1), ConsoleColor.Blue); }
public static List <MapDatas> ReadListSwfMap(string id) { List <MapDatas> MapList = new List <MapDatas>(); List <string> Files = Directory.GetFiles(Constants.MapsPath, "*.swf").ToList(); Files = Files.Where(x => x.Contains("\\" + id)).ToList(); SwfReader Reader; foreach (var mapFile in Files) { string path = mapFile; Reader = new SwfReader(path); Swf swf = Reader.ReadSwf(); IEnumerator enumerator = swf.Tags.GetEnumerator(); while (enumerator.MoveNext()) { BaseTag current = (BaseTag)enumerator.Current; if (current.ActionRecCount != 0) { string sb = ""; IEnumerator currentenumerator = current.GetEnumerator(); while (currentenumerator.MoveNext()) { Decompiler decompiler = new Decompiler(swf.Version); ArrayList actions = decompiler.Decompile((byte[])currentenumerator.Current); foreach (BaseAction obj in actions) { sb += obj.ToString(); } } SwfDecompiledMap content = ParseSwfMapDatas(sb); content.DecypheredMapData = Hash.DecypherData(content.CypheredMapData, MapKeyCracker.MapCrackKey(content.CypheredMapData)); GlobalMapsInfos.First(x => x.Id == content.Id).SwfDatas.MapId = path.Substring(path.IndexOf(id) + id.Length + 1, path.IndexOf(".swf") - (path.IndexOf(id) + id.Length + 1)); GlobalMapsInfos.First(x => x.Id == content.Id).SwfDatas = content; MapList.Add(GlobalMapsInfos.First(x => x.SwfDatas == content)); sb = ""; } } Reader.Close(); swf = null; } string firstValue = MapList.First().SwfDatas.DecypheredMapData; if (MapList.All(x => x.SwfDatas.DecypheredMapData == firstValue)) { return new List <MapDatas>() { MapList.First() } } ; return(MapList); }
public ActionResult Create([ModelBinder(typeof(TagViewModelModelBinder))] TagViewModel tagViewModel) { if (ModelState.IsValid) { BaseTag tag = Mapper.Map <TagViewModel, BaseTag>(tagViewModel); _tagRest.Post(tag); } return(RedirectToAction("Index")); }
public void AddOrderBy(BaseTag order, OrderType type) { OrderByItemTag tag = new OrderByItemTag() { Field = order, OrderType = type }; Items.Add(tag); }
/// <summary> /// Injects a range of tags in the current Swf. /// </summary> /// <param name="values">The values.</param> public void InjectTags(BaseTagCollection values) { IEnumerator enums = values.GetEnumerator(); for (int i = 0; enums.MoveNext(); i++) { BaseTag baseTag = (BaseTag)enums.Current; Add(baseTag); } }
public ActionResult Edit(TagViewModel tagViewModel) { if (ModelState.IsValid) { BaseTag tag = Mapper.Map <TagViewModel, BaseTag>(tagViewModel); _tagRest.Put(tag); } return(RedirectToAction("Index")); }
private void ParseAttributes(BaseTag tag) { BitArray ba = BitParser.GetBitValues(tag.Data); FileAttributes.UseDirectBlit = (bool)ba[16 + 1]; FileAttributes.UseGPU = (bool)ba[16 + 2]; FileAttributes.HasMetaData = (bool)ba[16 + 3]; FileAttributes.Actionscript3 = (bool)ba[16 + 4]; FileAttributes.UseNetwork = (bool)ba[16 + 7]; }
private bool CheckOnQuaternionTag(BaseObject ob) { // Iterate over the object's tags for (BaseTag tag = ob.GetFirstTag(); tag != null; tag = tag.GetNext()) { // In their sheer wisdom, the elders of the C4D SDK decided to not have a class of its own for the quaternion tag. // Neither will the world need a constant declaration for the type... int tagType = tag.GetTypeC4D(); if (tagType == 100001740) { BaseContainer data = tag.GetData(); int ii = data.GetInt32(1001); // QUAT_INTER (from tquaterninon.h) switch (ii) { case 1002: // INTER_SLERP, "Linear" break; case 1003: // INTER_SQUAD, "Spline" break; case 1004: // INTER_LOSCH, "Losch" break; } return(true); /* * for (int i = 0, id = 0; -1 != (id = data.GetIndexId(i)); i++) * { * if (data.GetType(id) == C4dApi.DA_LONG) * { * int ii = data.GetInt32(id); * switch (ii) * { * case 1002: // INTER_SLERP, * break; * case 1003: // INTER_SQUAD, * break; * case 1004: // INTER_LOSCH, * break; * } * } * if (data.GetType(id) == C4dApi.DA_REAL) * { * double d = data.GetFloat(id); * } * else if (data.GetType(id) == C4dApi.DA_VECTOR) * { * double3 v = data.GetVector(id); * } * } */ } } return(false); }
private static void WriteABCDataToDisk(BaseTag tag) { Console.WriteLine($"Writing \"{ABCDATA_FILE}\" to disk..."); using (BinaryWriter bw = new BinaryWriter(File.Open(ABCDATA_FILE_PATH, FileMode.Create, FileAccess.Write))) { bw.Write(((DoABC2Tag)tag).ABC); } Console.WriteLine($"File written to disk: \"{ABCDATA_FILE}\""); }
public void Put(BaseTag tag) { RestRequest request = new RestRequest("api/tag", Method.PUT); PostOrPut(request, tag); }
public Div(BaseTag parent) : base("div", parent) { }