public static void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s, ref BlamEngineTargetHandle value) where TDoc : class where TCursor : class { bool reading = s.IsReading; var build = reading ? EngineBuildHandle.None : value.Build; var platform_index = reading ? TypeExtensions.kNone : value.TargetPlatformIndex; var rsrc_model_index = reading ? TypeExtensions.kNone : value.ResourceModelIndex; EngineBuildHandle.Serialize(s, ref build); if (!build.IsNone) { if (EngineTargetPlatform.SerializeId(s, "targetPlatform", ref platform_index, true)) { EngineRegistry.SerializeResourceModelId(s, "resourceModel", ref rsrc_model_index, true); } } if (reading) { value = new BlamEngineTargetHandle(build, platform_index, rsrc_model_index); } }
public BlamEngineTargetHandle(EngineBuildHandle buildHandle, int platformIndex, int resourceModelIndex) { Contract.Requires <ArgumentOutOfRangeException>(EngineTargetPlatform.IsValidIndex(platformIndex)); Contract.Requires <ArgumentOutOfRangeException>(EngineRegistry.IsValidResourceModelIndex(resourceModelIndex) || (platformIndex.IsNone() && resourceModelIndex.IsNone())); InitializeHandle(out mHandle, buildHandle, platformIndex, resourceModelIndex); }
//internal uint Handle { get { return mHandle; } } static void InitializeHandle(out uint handle, EngineBuildHandle buildHandle, int platformIndex, int resourceModelIndex) { if (platformIndex.IsNone() && resourceModelIndex.IsNone()) { resourceModelIndex = 0; } var encoder = new Bitwise.HandleBitEncoder(); EngineRegistry.BitEncodeResourceModelIndex(ref encoder, resourceModelIndex); EngineTargetPlatform.BitEncodeIndex(ref encoder, platformIndex); encoder.Encode32(buildHandle.Handle, EngineBuildHandle.Bitmask); Contract.Assert(encoder.UsedBitCount == BlamEngineTargetHandle.BitCount); handle = encoder.GetHandle32(); }
public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { var repo = KSoft.Debug.TypeCheck.CastReference <EngineBuildRepository>(s.UserData); if (s.IsReading) { Repository = repo; } else { Contract.Assert(repo == Repository); } using (s.EnterUserDataBookmark(this)) { s.StreamAttribute("name", this, obj => obj.Name); s.StreamAttribute("project", this, obj => obj.ProjectName); EngineTargetPlatform.SerializeBitSet(s, ref mValidTargetPlatforms, "ValidTargetPlatforms"); using (var bm = s.EnterCursorBookmarkOpt("Revisions", Revisions, Predicates.HasItems)) if (bm.IsNotNull) { s.StreamableElements("Rev", Revisions); } } if (s.IsReading) { KSoft.Debug.ValueCheck.IsLessThanEqualTo("Too many registered branch revisions in " + Name, EngineBuildRevision.kMaxCount, Revisions.Count); Revisions.TrimExcess(); } }
public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { var engine = KSoft.Debug.TypeCheck.CastReference <BlamEngine>(s.Owner); if (s.IsReading) { Engine = engine; } else { Contract.Assert(engine == Engine); } using (s.EnterCursorBookmark("Repository")) using (s.EnterUserDataBookmark(this)) { s.StreamElement("Guid", this, obj => obj.Guid); EngineTargetPlatform.SerializeBitSet(s, ref mValidTargetPlatforms, "ValidTargetPlatforms"); using (var bm = s.EnterCursorBookmarkOpt("Branches", Branches, Predicates.HasItems)) if (bm.IsNotNull) { s.StreamableElements("Branch", Branches); } } if (s.IsReading) { KSoft.Debug.ValueCheck.IsLessThanEqualTo("Too many registered engine branches in " + Engine.Name, EngineBuildBranch.kMaxCount, Branches.Count); Branches.TrimExcess(); } }
public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { var branch = KSoft.Debug.TypeCheck.CastReference <EngineBuildBranch>(s.UserData); if (s.IsReading) { Branch = branch; } else { Contract.Assert(branch == Branch); } s.StreamAttribute("versionId", this, obj => obj.Version); s.StreamAttribute("build", this, obj => obj.BuildString); if (!s.StreamAttributeOpt("changeListId", this, obj => obj.ChangeList, Predicates.IsNotNone)) { ChangeList = TypeExtensions.kNoneInt32; } if (!s.StreamAttributeEnumOpt("productionStage", this, obj => obj.ProductionStage)) { ProductionStage = EngineProductionStage.Undefined; } if (!s.StreamAttributeEnumOpt("buildStringType", this, obj => obj.BuildStringType)) { BuildStringType = EngineBuildStringType.Build_DateTime; } s.StreamElement("Date", ref mDateString); s.StreamElement("Time", ref mTimeString); if (!s.StreamAttributeOpt("exportName", this, obj => obj.ExportName, Predicates.IsNotNullOrEmpty)) { ExportName = ""; } EngineTargetPlatform.SerializeBitSet(s, ref mValidTargetPlatforms, "ValidTargetPlatforms"); if (s.IsReading) { const string k_date_format_string = kDateFormat + " " + kDateTimeFormat + " " + kDateTimeOffsetFormat; string date_time_str = string.Format(Util.InvariantCultureInfo, "{0} {1}", mDateString, mTimeString); try { DateTime.ParseExact(date_time_str, k_date_format_string, System.Globalization.CultureInfo.InvariantCulture); } catch (FormatException ex) { s.ThrowReadException(ex); } if (ValidTargetPlatforms == EngineRegistry.NullValidTargetPlatforms) { throw new System.IO.InvalidDataException(string.Format(Util.InvariantCultureInfo, "{0}/{1} or its repository parents didn't specify any ValidTargetPlatforms", Branch.Name, BuildString)); } } }