Ejemplo n.º 1
0
 private void FillBuffer(TSourceOutput sourceRow)
 {
     if (LookupList == null)
     {
         LookupList = new List <TSourceOutput>();
     }
     LookupList.Add(sourceRow);
 }
        public void LookupList_key_indexer_returns_value()
        {
            var list = new LookupList<string, Item>(x => x.Name);
            var item = new Item {Name = "key", Value = 12};
            list.Add(item);

            list["key"].Should().Be(item);
        }
Ejemplo n.º 3
0
        public static void DisposeAll <T>(this LookupList <T> it)
            where T : IDisposable
        {
            if (it != null)
            {
                foreach (var item in it.AllObjects)
                {
                    item.Dispose();
                }

                it.Clear();
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Get lookup list by id
        /// </summary>
        /// <param name="id">id of DumpTruck to fetch</param>
        /// <response code="200">OK</response>
        /// <response code="404">DumpTruck not found</response>
        public virtual IActionResult LookuplistsIdGetAsync(int id)
        {
            bool exists = _context.LookupLists.Any(a => a.Id == id);

            if (exists)
            {
                LookupList result = _context.LookupLists.First(a => a.Id == id);

                return(new ObjectResult(new HetsResponse(result)));
            }

            // record not found
            return(new ObjectResult(new HetsResponse("HETS-01", ErrorViewModel.GetDescription("HETS-01", _configuration))));
        }
        /// <summary>
        /// Retrieves all Lookup objects by PageRequest
        /// </summary>
        /// <returns>A list of Lookup objects</returns>
        public LookupList GetPaged(PagedRequest request)
        {
            using (SqlCommand cmd = GetSPCommand(GETPAGEDLOOKUP))
            {
                AddParameter(cmd, pInt32Out("TotalRows"));
                AddParameter(cmd, pInt32("PageIndex", request.PageIndex));
                AddParameter(cmd, pInt32("RowPerPage", request.RowPerPage));
                AddParameter(cmd, pNVarChar("WhereClause", 4000, request.WhereClause));
                AddParameter(cmd, pNVarChar("SortColumn", 128, request.SortColumn));
                AddParameter(cmd, pNVarChar("SortOrder", 4, request.SortOrder));

                LookupList _LookupList = GetList(cmd, ALL_AVAILABLE_RECORDS);
                request.TotalRows = Convert.ToInt32(GetOutParameter(cmd, "TotalRows"));
                return(_LookupList);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="item"></param>
        /// <response code="201">DumpTruck created</response>
        public virtual IActionResult LookuplistsPostAsync(LookupList item)
        {
            var exists = _context.LookupLists.Any(a => a.Id == item.Id);

            if (exists)
            {
                _context.LookupLists.Update(item);
            }
            else
            {
                // record not found
                _context.LookupLists.Add(item);
            }
            // Save the changes
            _context.SaveChanges();
            return(new ObjectResult(item));
        }
Ejemplo n.º 7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id">id of DumpTruck to fetch</param>
        /// <param name="item"></param>
        /// <response code="200">OK</response>
        /// <response code="404">DumpTruck not found</response>
        public virtual IActionResult LookuplistsIdPutAsync(int id, LookupList item)
        {
            var exists = _context.LookupLists.Any(a => a.Id == id);

            if (exists && id == item.Id)
            {
                _context.LookupLists.Update(item);
                // Save the changes
                _context.SaveChanges();
                return(new ObjectResult(item));
            }
            else
            {
                // record not found
                return(new StatusCodeResult(404));
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Update lookup list
        /// </summary>
        /// <param name="id">id of DumpTruck to update</param>
        /// <param name="item"></param>
        /// <response code="200">OK</response>
        /// <response code="404">DumpTruck not found</response>
        public virtual IActionResult LookuplistsIdPutAsync(int id, LookupList item)
        {
            bool exists = _context.LookupLists.Any(a => a.Id == id);

            if (exists && id == item.Id)
            {
                _context.LookupLists.Update(item);

                // save the changes
                _context.SaveChanges();

                return(new ObjectResult(new HetsResponse(item)));
            }

            // record not found
            return(new ObjectResult(new HetsResponse("HETS-01", ErrorViewModel.GetDescription("HETS-01", _configuration))));
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Retrieve list of Lookup.
        /// </summary>
        /// <param name="fillChild"></param>
        /// <returns>List of Lookup</returns>
        public LookupList GetAll(bool fillChild)
        {
            LookupList lookupList = new LookupList();

            using (LookupDataAccess data = new LookupDataAccess(ClientContext))
            {
                lookupList = data.GetAll();
            }
            if (fillChild)
            {
                foreach (Lookup lookupObject in lookupList)
                {
                    FillLookupWithChilds(lookupObject, fillChild);
                }
            }
            return(lookupList);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Delete lookup list
        /// </summary>
        /// <param name="id">id of DumpTruck to delete</param>
        /// <response code="200">OK</response>
        /// <response code="404">DumpTruck not found</response>
        public virtual IActionResult LookuplistsIdDeletePostAsync(int id)
        {
            bool exists = _context.LookupLists.Any(a => a.Id == id);

            if (exists)
            {
                LookupList item = _context.LookupLists.First(a => a.Id == id);

                if (item != null)
                {
                    _context.LookupLists.Remove(item);

                    // save the changes
                    _context.SaveChanges();
                }

                return(new ObjectResult(new HetsResponse(item)));
            }

            // record not found
            return(new ObjectResult(new HetsResponse("HETS-01", ErrorViewModel.GetDescription("HETS-01", _configuration))));
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Updates the properties on the represented business object
        /// </summary>
        public override void ApplyChangesToBusinessObject()
        {
            if (_businessObject == null || _comboBox.SelectedIndex == -1)
            {
                return;
            }
            var    selectedOption = GetSelectedOption();
            object newValue       = null;

            if (LookupList.ContainsKey(selectedOption))
            {
                newValue = !string.IsNullOrEmpty(selectedOption)
                               ? LookupList[selectedOption]
                               : null;
            }
            if (newValue != null)
            {
                object propertyValue = GetPropertyValue();
                if (newValue.Equals(Guid.Empty))
                {
                    if (propertyValue != null)
                    {
                        SetPropertyValue(null);
                    }
                }
                else if (propertyValue == null ||
                         !newValue.Equals(propertyValue))
                {
                    SetPropertyValue(newValue);
                }
            }
            else
            {
                SetPropertyValue(null);
            }
        }
Ejemplo n.º 12
0
 public virtual IActionResult LookuplistsPost([FromBody] LookupList item)
 {
     return(this._service.LookuplistsPostAsync(item));
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EndpointService"/> class.
 /// </summary>
 public EndpointService( )
 {
     Endpoints  = new LookupList <String, EndpointInfo> ( );
     Properties = new List <PropertyKeyValuePair <string, object> > ( );
     Gists      = new List <Gist> ( );
 }
Ejemplo n.º 14
0
        public async Task DoUpdate()
        {
            Logger.Debug("Starting the update process for codes with ListID equal to" + ListID);

            Logger.Debug("Retrieving latest version from the CommonWealth Web Service.");
            //Pull the highest version number from MCM
            DTO.LookupListsImportDTO versionsList = await LoadVersions();

            var latestVersion = versionsList.Results.LatestVersion.VersionID;

            //Query PMN database for the highest version number (our local version number)
            var localVersion = db.LookupLists.Where(t => t.ListId == this.ListID).Select(j => j.Version).ToString();

            //If the latest version is not the local Version, delete codes with the current ListID, and then import the new set of codes
            if (latestVersion != localVersion)
            {
                string importVersionUrl = "";
                string categoriesUrl    = "";
                if (ListID == Lpp.Dns.DTO.Enums.Lists.HCPCSProcedures)
                {
                    importVersionUrl = versionUrl + "/" + latestVersion + "/code?columns=code,category,short_description,data_end";
                    //no categories for hcpcs in pmn database (the categories in the code selector are grouped by code # ranges)
                    //but there are categories in the MCM data so import them here
                    categoriesUrl = versionUrl + "/" + latestVersion + "/code?columns=category";
                }
                if (ListID == Lpp.Dns.DTO.Enums.Lists.GenericName)
                {
                    importVersionUrl = versionUrl + "/" + latestVersion + "/code?columns=generic_name,drug_class,data_end";
                    //the categories for Generic Drug Names are the drug class.
                    categoriesUrl = versionUrl + "/" + latestVersion + "/code?columns=drug_class";
                }
                if (ListID == Lpp.Dns.DTO.Enums.Lists.DrugClass)
                {
                    importVersionUrl = versionUrl + "/" + latestVersion + "/code?columns=drug_class,data_end";
                    //the categories for drug class are the drug class (the category is just a repetition of the drug class name)
                    categoriesUrl = versionUrl + "/" + latestVersion + "/code?columns=drug_class";
                }
                if (this.ListID == Lpp.Dns.DTO.Enums.Lists.ICD9Diagnosis ||
                    this.ListID == Lpp.Dns.DTO.Enums.Lists.ICD9Diagnosis4Digits ||
                    this.ListID == Lpp.Dns.DTO.Enums.Lists.ICD9Diagnosis5Digits ||
                    this.ListID == Lpp.Dns.DTO.Enums.Lists.ICD9Procedures ||
                    this.ListID == Lpp.Dns.DTO.Enums.Lists.ICD9Procedures4Digits)
                {
                    importVersionUrl = versionUrl + "/" + latestVersion + "/code?" + codeLength + "&columns=code,code_unformatted,category,short_description,data_end";
                    categoriesUrl    = versionUrl + "/" + latestVersion + "/code?columns=category";
                }

                //SPAN- Diagnosis (ListID = 10) represents all diagnostic codes (Listid=4,7,8)
                //SPAN- Procedure (ListID = 11) represents all procedure codes (Listid = 5,9)
                if (this.ListID == Lpp.Dns.DTO.Enums.Lists.ICD9Diagnosis ||
                    this.ListID == Lpp.Dns.DTO.Enums.Lists.ICD9Diagnosis4Digits ||
                    this.ListID == Lpp.Dns.DTO.Enums.Lists.ICD9Diagnosis5Digits)
                {
                    this.SpanListID = DTO.Enums.Lists.SPANDiagnosis;
                }
                if (this.ListID == Lpp.Dns.DTO.Enums.Lists.ICD9Procedures ||
                    this.ListID == Lpp.Dns.DTO.Enums.Lists.ICD9Procedures4Digits)
                {
                    this.SpanListID = DTO.Enums.Lists.SPANProcedure;
                }


                Logger.Debug("Loading codes and categories from CommonWealth Web Service");
                //Pull in all codes from MCM (deserialize into a list of objects)
                LookupListValuesImportDTO codeValuesList = await LoadValues(importVersionUrl);

                //Pull in all categories from MCM
                LookupListCategoryImportDTO categoriesList = new LookupListCategoryImportDTO();
                if (ListID != DTO.Enums.Lists.HCPCSProcedures)
                {
                    categoriesList = await LoadCategories(categoriesUrl);
                }
                Logger.Debug("Deleting codes and categories with ListId equal to " + ListID);
                //Delete categories and codes for this ListID from the database
                await db.Database.ExecuteSqlCommandAsync("Delete from LookupListValues where ListId= {0}", ListID);

                await db.Database.ExecuteSqlCommandAsync("Delete from LookupListCategories where ListId= {0}", ListID);

                //Delete Span diagnosis and procedure categories only once
                if (this.ListID == DTO.Enums.Lists.ICD9Diagnosis || this.ListID == DTO.Enums.Lists.ICD9Procedures)
                {
                    await db.Database.ExecuteSqlCommandAsync("Delete from LookupListCategories where ListId= {0}", SpanListID);

                    await db.Database.ExecuteSqlCommandAsync("Delete from LookupListValues where ListId= {0}", SpanListID);
                }
                await db.SaveChangesAsync();



                var i = 1;
                int numOfCategories = 0;
                if (this.ListID != DTO.Enums.Lists.HCPCSProcedures)
                {
                    numOfCategories = categoriesList.Categories.Count(); //for debugging purposes
                    foreach (var c in categoriesList.Categories)
                    {
                        var categoryname = c[0];

                        var result = new LookupListCategory
                        {
                            ListId       = this.ListID,
                            CategoryName = categoryname,
                            CategoryId   = i
                        };
                        if (result.CategoryName == "")
                        {
                            result.CategoryName = "UNDEFINED";
                        }
                        //Add new category to list that will update the database
                        categoriesToAdd.Add(result);
                        i = i + 1;
                    }
                }

                //Add categories for Span Diagnostics (only add once for diagnosis codes and once for procedure codes)
                if (this.ListID == DTO.Enums.Lists.ICD9Diagnosis || this.ListID == DTO.Enums.Lists.ICD9Procedures)
                {
                    var k = 1;
                    foreach (var c in categoriesList.Categories)
                    {
                        var categoryName = c[0];

                        var result = new LookupListCategory
                        {
                            ListId       = SpanListID,
                            CategoryName = categoryName,
                            CategoryId   = k
                        };
                        if (result.CategoryName == "")
                        {
                            result.CategoryName = "UNDEFINED";
                        }
                        spanCategoriesToAdd.Add(result);
                        k = k + 1;
                    }
                }

                Logger.Debug("Beginning of Update for  " + numOfCategories + "categories.");
                //Add the categories to database
                db.LookupListCategories.AddRange(categoriesToAdd);
                db.LookupListCategories.AddRange(spanCategoriesToAdd);

                Logger.Debug("Finished processing import of categories. Beginning Saving.");
                await db.SaveChangesAsync();

                Logger.Debug("Finished saving of categories.");
                //Add the codes to the database
                //empty code list:
                List <LookupListValue> codesToAdd = new List <LookupListValue>();
                var numCodes = codesToAdd.Count();
                //for ICD9 codes:
                if (this.ListID == Lpp.Dns.DTO.Enums.Lists.ICD9Diagnosis ||
                    this.ListID == Lpp.Dns.DTO.Enums.Lists.ICD9Diagnosis4Digits ||
                    this.ListID == Lpp.Dns.DTO.Enums.Lists.ICD9Diagnosis5Digits ||
                    this.ListID == Lpp.Dns.DTO.Enums.Lists.ICD9Procedures ||
                    this.ListID == Lpp.Dns.DTO.Enums.Lists.ICD9Procedures4Digits)
                {
                    foreach (var codeToAdd in codeValuesList.Codes)
                    {
                        var code             = codeToAdd[0];
                        var codeUnformatted  = codeToAdd[1];
                        var codeCategoryName = codeToAdd[2];
                        var codeName         = codeToAdd[3];
                        var expiration       = codeToAdd[4];

                        var codeCategory = categoriesToAdd.Where(ct => ct.CategoryName == codeCategoryName).FirstOrDefault();

                        var categoryID = codeCategory.IsEmpty() ? 0 : codeCategory.CategoryId;

                        var newCode = new LookupListValue
                        {
                            ListId               = this.ListID,
                            CategoryId           = categoryID,
                            ItemName             = codeName,
                            ItemCode             = code,
                            ItemCodeWithNoPeriod = codeUnformatted,
                            ExpireDate           = null
                        };
                        //also add code to Span
                        var newSpanCode = new LookupListValue
                        {
                            ListId               = this.SpanListID,
                            CategoryId           = categoryID,
                            ItemName             = codeName,
                            ItemCode             = code,
                            ItemCodeWithNoPeriod = codeUnformatted,
                            ExpireDate           = null
                        };
                        if (!expiration.IsNullOrEmpty())
                        {
                            var      year           = expiration.Substring(0, 4).ToInt32();
                            var      month          = expiration.Substring(4, 2).ToInt32();
                            var      day            = expiration.Substring(6, 2).ToInt32();
                            DateTime expirationDate = new DateTime(year, month, day);
                            newCode.ExpireDate     = expirationDate;
                            newSpanCode.ExpireDate = expirationDate;
                        }

                        codesToAdd.Add(newCode);
                        codesToAdd.Add(newSpanCode);
                    }
                    //push entire array
                    Logger.Debug("Beginning of Update for" + numCodes + "codes with ListId equal to " + ListID);
                    db.LookupListValues.AddRange(codesToAdd);
                }

                //Update for HCPCS codes
                if (this.ListID == Dns.DTO.Enums.Lists.HCPCSProcedures)
                {
                    foreach (var codeToAdd in codeValuesList.Codes)
                    {
                        var code = codeToAdd[0];
                        //var codeCategoryName = codeToAdd[1];
                        var codeDescription = codeToAdd[2];
                        var expiration      = codeToAdd[3];

                        //var codeCategory = categoriesToAdd.Where(ct => ct.CategoryName == codeCategoryName).FirstOrDefault();
                        //var categoryID = codeCategory.IsEmpty() ? 0 : codeCategory.CategoryId;

                        if (codeDescription == "" || codeDescription == null)
                        {
                            codeDescription = "UNDEFINED";
                        }

                        var newCode = new LookupListValue
                        {
                            ListId               = this.ListID,
                            CategoryId           = 0,
                            ItemName             = codeDescription,
                            ItemCode             = code,
                            ItemCodeWithNoPeriod = code,
                            ExpireDate           = null
                        };
                        if (!expiration.IsNullOrEmpty())
                        {
                            var      year           = expiration.Substring(0, 4).ToInt32();
                            var      month          = expiration.Substring(4, 2).ToInt32();
                            var      day            = expiration.Substring(6, 2).ToInt32();
                            DateTime expirationDate = new DateTime(year, month, day);
                            newCode.ExpireDate = expirationDate;
                        }

                        if (code != null && code != "")
                        {
                            codesToAdd.Add(newCode);
                        }
                    }
                    //Some repeated codes
                    //IEnumerable<LookupListValue> codesDistinct = codesToAdd.DistinctBy(a => new { a.ItemName, a.ItemCode, a.CategoryId }).ToList();
                    //push entire array
                    numCodes = codesToAdd.Count();
                    Logger.Debug("Beginning of Update for" + numCodes + " codes with ListId equal to " + ListID);
                    db.LookupListValues.AddRange(codesToAdd);
                }

                //Update for Generic Names
                if (this.ListID == Dns.DTO.Enums.Lists.GenericName)
                {
                    foreach (var codeToAdd in codeValuesList.Codes)
                    {
                        var name       = codeToAdd[0];
                        var drugClass  = codeToAdd[1];
                        var expiration = codeToAdd[2];

                        var codeCategory = categoriesToAdd.Where(ct => ct.CategoryName == drugClass).FirstOrDefault();
                        var categoryID   = codeCategory.IsEmpty() ? 0 : codeCategory.CategoryId;

                        var newCode = new LookupListValue
                        {
                            ListId               = this.ListID,
                            CategoryId           = categoryID,
                            ItemName             = name,
                            ItemCode             = name,
                            ItemCodeWithNoPeriod = name,
                            ExpireDate           = null
                        };

                        if (!expiration.IsNullOrEmpty())
                        {
                            var      year           = expiration.Substring(0, 4).ToInt32();
                            var      month          = expiration.Substring(4, 2).ToInt32();
                            var      day            = expiration.Substring(6, 2).ToInt32();
                            DateTime expirationDate = new DateTime(year, month, day);
                            newCode.ExpireDate = expirationDate;
                        }

                        if (name != null && name != "")
                        {
                            codesToAdd.Add(newCode);
                        }
                    }
                    Logger.Debug("Beginning of Update for" + numCodes + " codes with ListId equal to " + ListID);
                    db.LookupListValues.AddRange(codesToAdd);
                }

                //Update for Drug Classes
                if (this.ListID == Dns.DTO.Enums.Lists.DrugClass)
                {
                    foreach (var codeToAdd in codeValuesList.Codes)
                    {
                        var drugClass  = codeToAdd[0];
                        var expiration = codeToAdd[1];

                        var codeCategory = categoriesToAdd.Where(ct => ct.CategoryName == drugClass).FirstOrDefault();
                        var categoryID   = codeCategory.IsEmpty() ? 0 : codeCategory.CategoryId;

                        var newCode = new LookupListValue
                        {
                            ListId               = this.ListID,
                            CategoryId           = categoryID,
                            ItemName             = drugClass,
                            ItemCode             = drugClass,
                            ItemCodeWithNoPeriod = "''",
                            ExpireDate           = null
                        };

                        if (!expiration.IsNullOrEmpty())
                        {
                            var      year           = expiration.Substring(0, 4).ToInt32();
                            var      month          = expiration.Substring(4, 2).ToInt32();
                            var      day            = expiration.Substring(6, 2).ToInt32();
                            DateTime expirationDate = new DateTime(year, month, day);
                            newCode.ExpireDate = expirationDate;
                        }
                        if (drugClass != null && drugClass != "")
                        {
                            codesToAdd.Add(newCode);
                        }
                    }
                    Logger.Debug("Beginning of Update for " + numCodes + " codes with ListId equal to " + ListID);
                    db.LookupListValues.AddRange(codesToAdd);
                }

                LookupList currentLookupList = db.LookupLists.Where(l => l.ListId == ListID).FirstOrDefault();
                currentLookupList.Version = latestVersion;
                if (SpanListID == DTO.Enums.Lists.SPANDiagnosis || SpanListID == DTO.Enums.Lists.SPANProcedure)
                {
                    LookupList currentSpanLookupList = db.LookupLists.Where(s => s.ListId == SpanListID).FirstOrDefault();
                    currentSpanLookupList.Version = latestVersion;
                }
                Logger.Debug("Finished processing import of codes. Beginning Saving.");
                await db.SaveChangesAsync();

                Logger.Debug("Finished Saving of codes.");
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Position glyphs according to features defined in the font.
        /// </summary>
        /// <param name="Font">In: Font access interface</param>
        /// <param name="workspace">In: Workspace for layout engine</param>
        /// <param name="ScriptTag">In: Script tag</param>
        /// <param name="LangSysTag">In: LangSys tag</param>
        /// <param name="Metrics">In: LayoutMetrics</param>
        /// <param name="FeatureSet">In: List of features to apply</param>
        /// <param name="featureCount">In: Actual number of features in <paramref name="FeatureSet"/></param>
        /// <param name="featureSetOffset">In: offset of input characters inside FeatureSet</param>
        /// <param name="CharCount">In: Characters count (i.e. <paramref name="Charmap"/>.Length);</param>
        /// <param name="Charmap">In: Char to glyph mapping</param>
        /// <param name="Glyphs">In/out: List of GlyphInfo structs</param>
        /// <param name="Advances">In/out: Glyphs adv.widths</param>
        /// <param name="Offsets">In/out: Glyph offsets</param>
        /// <returns>Substitution result</returns>
        internal static OpenTypeLayoutResult PositionGlyphs(
            IOpenTypeFont Font,
            OpenTypeLayoutWorkspace workspace,
            uint ScriptTag,
            uint LangSysTag,
            LayoutMetrics Metrics,
            Feature[]               FeatureSet,
            int featureCount,
            int featureSetOffset,
            int CharCount,
            UshortList Charmap,
            GlyphInfoList Glyphs,
            int *Advances,
            LayoutOffset *Offsets
            )
        {
            try
            {
                FontTable GposTable = Font.GetFontTable(OpenTypeTags.GPOS);
                if (!GposTable.IsPresent)
                {
                    return(OpenTypeLayoutResult.ScriptNotFound);
                }

                GPOSHeader GposHeader = new GPOSHeader(0);
                ScriptList ScriptList = GposHeader.GetScriptList(GposTable);

                ScriptTable Script = ScriptList.FindScript(GposTable, ScriptTag);
                if (Script.IsNull)
                {
                    return(OpenTypeLayoutResult.ScriptNotFound);
                }

                LangSysTable LangSys = Script.FindLangSys(GposTable, LangSysTag);
                if (LangSys.IsNull)
                {
                    return(OpenTypeLayoutResult.LangSysNotFound);
                }

                FeatureList FeatureList = GposHeader.GetFeatureList(GposTable);
                LookupList  LookupList  = GposHeader.GetLookupList(GposTable);

                LayoutEngine.ApplyFeatures(
                    Font,
                    workspace,
                    OpenTypeTags.GPOS,
                    GposTable,
                    Metrics,
                    LangSys,
                    FeatureList,
                    LookupList,
                    FeatureSet,
                    featureCount,
                    featureSetOffset,
                    CharCount,
                    Charmap,
                    Glyphs,
                    Advances,
                    Offsets
                    );
            }
            catch (FileFormatException)
            {
                return(OpenTypeLayoutResult.BadFontTable);
            }

            return(OpenTypeLayoutResult.Success);
        }
Ejemplo n.º 16
0
/* This is unused code, but will be used later so it is just commented out for now.
 *
 *      /// <summary>
 *      /// Enumerates scripts in a font
 *      /// </summary>
 *      internal static OpenTypeLayoutResult GetScriptList (
 *          IOpenTypeFont       Font,     // In: Font access interface
 *          out TagInfo[]       Scripts   // Out: Array of scripts supported
 *          )
 *      {
 *          ushort i;
 *          ushort GposNewTags;
 *
 *          Scripts=null; // Assignment required, because of out attribute.
 *                        // This value should be owerwritten later.
 *
 *          try
 *          {
 *              FontTable GsubTable = Font.GetFontTable(OpenTypeTags.GSUB);
 *              FontTable GposTable = Font.GetFontTable(OpenTypeTags.GPOS);
 *
 *              GSUBHeader GsubHeader = new GSUBHeader(0);
 *              GPOSHeader GposHeader = new GPOSHeader(0);
 *
 *              ScriptList GsubScriptList;
 *              ScriptList GposScriptList;
 *              ushort GsubScriptCount;
 *              ushort GposScriptCount;
 *
 *              if (GsubTable.IsNotPresent && GposTable.IsNotPresent)
 *              {
 *                  Scripts = Array.Empty<TagInfo>();
 *                  return OpenTypeLayoutResult.Success;
 *              }
 *
 *              if (GsubTable.IsPresent)
 *              {
 *                  GsubScriptList  = GsubHeader.GetScriptList(GsubTable);
 *                  GsubScriptCount = GsubScriptList.GetScriptCount(GsubTable);
 *              }
 *              else
 *              {
 *                  GsubScriptList = new ScriptList(FontTable.InvalidOffset);
 *                  GsubScriptCount = 0;
 *              }
 *
 *              if (GposTable.IsPresent)
 *              {
 *                  GposScriptList  = GposHeader.GetScriptList(GposTable);
 *                  GposScriptCount = GposScriptList.GetScriptCount(GposTable);
 *              }
 *              else
 *              {
 *                  GposScriptList = new ScriptList(FontTable.InvalidOffset);
 *                  GposScriptCount = 0;
 *              }
 *
 *              //This is true in most cases that there is no new tags in GPOS.
 *              //So, we allocate this array then check GPOS for new tags
 *              Scripts = new TagInfo[GsubScriptCount];
 *
 *              for(i=0; i<GsubScriptCount; i++)
 *              {
 *                  Scripts[i].Tag      = GsubScriptList.GetScriptTag(GsubTable,i);
 *                  Scripts[i].TagFlags = TagInfoFlags.Substitution;
 *              }
 *
 *              //Check GPOS for tags that is not in GSUB
 *              GposNewTags=0;
 *
 *              for(i=0;i<GposScriptCount;i++)
 *              {
 *                  uint GposTag = GsubScriptList.GetScriptTag(GposTable,i);
 *                  if (TagInfo.IsNewTag(Scripts,GposTag)) GposNewTags++;
 *              }
 *
 *              //append new tags to ScriptTags if any exists
 *              if (GposNewTags>0)
 *              {
 *                  int CurrentScriptIndex=GposScriptCount;
 *
 *                  //Allocate new array to fit all tags
 *                  TagInfo[] tmp = Scripts;
 *                  Scripts = new TagInfo[GsubScriptCount+GposNewTags];
 *                  Array.Copy(tmp,0,Scripts,0,tmp.Length);
 *
 *                  for(i=0;i<GposScriptCount;i++)
 *                  {
 *                      uint GposTag = GsubScriptList.GetScriptTag(GposTable,i);
 *                      if (TagInfo.IsNewTag(Scripts,GposTag))
 *                      {
 *                          Scripts[CurrentScriptIndex].Tag=GposTag;
 *                          Scripts[CurrentScriptIndex].TagFlags
 *                              = TagInfoFlags.Positioning;
 ++CurrentScriptIndex;
 *                      }
 *                      else
 *                      {
 *                          int ScriptIndex = TagInfo.GetTagIndex(Scripts,GposTag);
 *                          Scripts[ScriptIndex].TagFlags |= TagInfoFlags.Positioning;
 *                      }
 *                  }
 *
 *                  Debug.Assert(CurrentScriptIndex==Scripts.Length);
 *              }
 *          }
 *          catch (FileFormatException)
 *          {
 *              return OpenTypeLayoutResult.BadFontTable;
 *          }
 *
 *          return OpenTypeLayoutResult.Success;
 *      }
 *
 *
 *      ///<summary>
 *      /// Enumerates language systems for script
 *      /// </summary>
 *      internal static OpenTypeLayoutResult  GetLangSysList (
 *          IOpenTypeFont   Font,       // In: Font access interface
 *          uint            ScriptTag,  // In: Script tag
 *          out TagInfo[]   LangSystems // Out: Array of LangSystems for Script
 *          )
 *      {
 *          ushort i;
 *          ushort GposNewTags;
 *
 *          LangSystems=null; // Assignment required, because of out attribute.
 *                            // This value should be owerwritten later.
 *
 *          try
 *          {
 *              FontTable GsubTable = Font.GetFontTable(OpenTypeTags.GSUB);
 *              FontTable GposTable = Font.GetFontTable(OpenTypeTags.GPOS);
 *
 *              GSUBHeader GsubHeader = new GSUBHeader(0);
 *              GPOSHeader GposHeader = new GPOSHeader(0);
 *
 *              ScriptList GsubScriptList;
 *              ScriptList GposScriptList;
 *              ScriptTable GsubScript;
 *              ScriptTable GposScript;
 *              ushort GsubLangSysCount;
 *              ushort GposLangSysCount;
 *
 *              if (GsubTable.IsNotPresent && GposTable.IsNotPresent)
 *              {
 *                  return OpenTypeLayoutResult.ScriptNotFound;
 *              }
 *
 *              if (GsubTable.IsPresent)
 *              {
 *                  GsubScriptList = GsubHeader.GetScriptList(GsubTable);
 *                  GsubScript = GsubScriptList.FindScript(GsubTable,ScriptTag);
 *              }
 *              else
 *              {
 *                  GsubScript = new ScriptTable(FontTable.InvalidOffset);
 *              }
 *
 *              if (GposTable.IsPresent)
 *              {
 *                  GposScriptList  = GposHeader.GetScriptList(GposTable);
 *                  GposScript = GposScriptList.FindScript(GposTable,ScriptTag);
 *              }
 *              else
 *              {
 *                  GposScript = new ScriptTable(FontTable.InvalidOffset);
 *              }
 *
 *              if (GsubScript.IsNull && GposScript.IsNull)
 *              {
 *                  return OpenTypeLayoutResult.ScriptNotFound;
 *              }
 *
 *              if (!GsubScript.IsNull)
 *              {
 *                  GsubLangSysCount = GsubScript.GetLangSysCount(GsubTable);
 *              }
 *              else
 *              {
 *                  GsubLangSysCount = 0;
 *              }
 *
 *              if (!GposScript.IsNull)
 *              {
 *                  GposLangSysCount = GposScript.GetLangSysCount(GposTable);
 *              }
 *              else
 *              {
 *                  GposLangSysCount = 0;
 *              }
 *
 *              //This is true in most cases that there is no new tags in GPOS.
 *              //So, we allocate this array then check GPOS for new tags
 *              ushort CurrentLangSysIndex;
 *
 *              if (GsubScript.IsDefaultLangSysExists(GsubTable))
 *              {
 *                  LangSystems = new TagInfo[GsubLangSysCount+1];
 *                  LangSystems[0].Tag      = (uint)OpenTypeTags.dflt;
 *                  LangSystems[0].TagFlags = TagInfoFlags.Substitution;
 *                  CurrentLangSysIndex = 1;
 *              }
 *              else
 *              {
 *                  LangSystems = new TagInfo[GsubLangSysCount];
 *                  CurrentLangSysIndex = 0;
 *              }
 *
 *              for(i=0; i<GsubLangSysCount; i++)
 *              {
 *                  LangSystems[CurrentLangSysIndex].Tag = GsubScript.GetLangSysTag(GsubTable,i);
 *                  LangSystems[CurrentLangSysIndex].TagFlags = TagInfoFlags.Substitution;
 ++CurrentLangSysIndex;
 *              }
 *
 *              //Check GPOS for tags that is not in GSUB
 *              GposNewTags=0;
 *
 *              if (!GposScript.IsNull)
 *              {
 *                  if (GposScript.IsDefaultLangSysExists(GposTable) &&
 *                      TagInfo.IsNewTag(LangSystems,(uint)OpenTypeTags.dflt))
 *                  {
 ++GposNewTags;
 *                  }
 *
 *                  for(i=0;i<GposLangSysCount;i++)
 *                  {
 *                      uint GposTag = GsubScript.GetLangSysTag(GposTable,i);
 *                      if (TagInfo.IsNewTag(LangSystems,GposTag))
 *                      {
 ++GposNewTags;
 *                      }
 *                  }
 *              }
 *
 *              Debug.Assert(CurrentLangSysIndex==LangSystems.Length);
 *
 *              //append new tags to ScriptTags if any exists
 *              if (GposNewTags>0)
 *              {
 *                  //Allocate new array to fit all tags
 *                  TagInfo[] tmp = LangSystems;
 *                  LangSystems = new TagInfo[GsubLangSysCount+GposNewTags];
 *                  Array.Copy(tmp,0,LangSystems,0,tmp.Length);
 *
 *                  if (GposScript.IsDefaultLangSysExists(GposTable))
 *                  {
 *                      if (TagInfo.IsNewTag(LangSystems,(uint)OpenTypeTags.dflt))
 *                      {
 *                          LangSystems[CurrentLangSysIndex].Tag = (uint)OpenTypeTags.dflt;
 *                          LangSystems[CurrentLangSysIndex].TagFlags = TagInfoFlags.Positioning;
 ++CurrentLangSysIndex;
 *                      }
 *                      else
 *                      {
 *                          int LangSysIndex = TagInfo.GetTagIndex(LangSystems,(uint)OpenTypeTags.dflt);
 *                          LangSystems[LangSysIndex].TagFlags |= TagInfoFlags.Positioning;
 *                      }
 *                  }
 *
 *                  for(i=0;i<GposLangSysCount;i++)
 *                  {
 *                      uint GposTag = GposScript.GetLangSysTag(GposTable,i);
 *
 *                      if (TagInfo.IsNewTag(LangSystems,GposTag))
 *                      {
 *                          LangSystems[CurrentLangSysIndex].Tag = GposTag;
 *                          LangSystems[CurrentLangSysIndex].TagFlags = TagInfoFlags.Positioning;
 ++CurrentLangSysIndex;
 *                      }
 *                      else
 *                      {
 *                          int LangSysIndex = TagInfo.GetTagIndex(LangSystems,GposTag);
 *                          LangSystems[LangSysIndex].TagFlags |= TagInfoFlags.Positioning;
 *                      }
 *                  }
 *
 *                  Debug.Assert(CurrentLangSysIndex==LangSystems.Length);
 *              }
 *          }
 *          catch (FileFormatException)
 *          {
 *              return OpenTypeLayoutResult.BadFontTable;
 *          }
 *
 *          return OpenTypeLayoutResult.Success;
 *      }
 *
 *
 *      /// <summary>
 *      /// Enumerates features in a language system
 *      /// </summary>
 *      internal static OpenTypeLayoutResult  GetFeatureList (
 *          IOpenTypeFont   Font,           // In: Font access interface
 *          uint            ScriptTag,      // In: Script tag
 *          uint            LangSysTag,     // In: LangSys tag
 *          out TagInfo[]   Features        // Out: Array of features
 *          )
 *      {
 *          ushort i;
 *          ushort GposNewTags;
 *
 *          Features=null; // Assignment required, because of out attribute.
 *                         // This value should be owerwritten later.
 *
 *          try
 *          {
 *              FontTable GsubTable = Font.GetFontTable(OpenTypeTags.GSUB);
 *              FontTable GposTable = Font.GetFontTable(OpenTypeTags.GPOS);
 *
 *              GSUBHeader GsubHeader = new GSUBHeader(0);
 *              GPOSHeader GposHeader = new GPOSHeader(0);
 *
 *              ScriptList GsubScriptList;
 *              ScriptList GposScriptList;
 *              ScriptTable GsubScript;
 *              ScriptTable GposScript;
 *              LangSysTable GsubLangSys;
 *              LangSysTable GposLangSys;
 *              ushort GsubFeatureCount;
 *              ushort GposFeatureCount;
 *              FeatureList GsubFeatureList;
 *              FeatureList GposFeatureList;
 *
 *
 *              if (GsubTable.IsNotPresent && GposTable.IsNotPresent)
 *              {
 *                  return OpenTypeLayoutResult.ScriptNotFound;
 *              }
 *
 *              if (GsubTable.IsPresent)
 *              {
 *                  GsubScriptList  = GsubHeader.GetScriptList(GsubTable);
 *                  GsubScript      = GsubScriptList.FindScript(GsubTable,ScriptTag);
 *                  GsubLangSys     = GsubScript.FindLangSys(GsubTable,LangSysTag);
 *                  GsubFeatureList = GsubHeader.GetFeatureList(GsubTable);
 *              }
 *              else
 *              {
 *                  GsubScript = new ScriptTable(FontTable.InvalidOffset);
 *                  GsubLangSys = new LangSysTable(FontTable.InvalidOffset);
 *                  GsubFeatureList = new FeatureList(FontTable.InvalidOffset);
 *              }
 *
 *              if (GposTable.IsPresent)
 *              {
 *                  GposScriptList  = GposHeader.GetScriptList(GposTable);
 *                  GposScript      = GposScriptList.FindScript(GposTable,ScriptTag);
 *                  GposLangSys     = GposScript.FindLangSys(GposTable,LangSysTag);
 *                  GposFeatureList = GposHeader.GetFeatureList(GposTable);
 *              }
 *              else
 *              {
 *                  GposScript = new ScriptTable(FontTable.InvalidOffset);
 *                  GposLangSys = new LangSysTable(FontTable.InvalidOffset);
 *                  GposFeatureList = new FeatureList(FontTable.InvalidOffset);
 *              }
 *
 *              if (GsubScript.IsNull && GposScript.IsNull)
 *              {
 *                  return OpenTypeLayoutResult.ScriptNotFound;
 *              }
 *
 *              if (GsubLangSys.IsNull && GposLangSys.IsNull)
 *              {
 *                  return OpenTypeLayoutResult.LangSysNotFound;
 *              }
 *
 *              if (!GsubLangSys.IsNull)
 *              {
 *                  GsubFeatureCount = GsubLangSys.FeatureCount(GsubTable);
 *              }
 *              else
 *              {
 *                  GsubFeatureCount = 0;
 *              }
 *
 *              if (!GposLangSys.IsNull)
 *              {
 *                  GposFeatureCount = GposLangSys.FeatureCount(GposTable);
 *              }
 *              else
 *              {
 *                  GposFeatureCount = 0;
 *              }
 *
 *              Features = new TagInfo[GsubFeatureCount];
 *              int CurrentFeatureIndex = 0;
 *
 *              for(i=0; i<GsubFeatureCount; i++)
 *              {
 *                  ushort FeatureIndex = GsubLangSys.GetFeatureIndex(GsubTable,i);
 *                  Features[CurrentFeatureIndex].Tag = GsubFeatureList.FeatureTag(GsubTable,FeatureIndex);
 *                  Features[CurrentFeatureIndex].TagFlags = TagInfoFlags.Substitution;
 ++CurrentFeatureIndex;
 *              }
 *
 *              Debug.Assert(CurrentFeatureIndex==Features.Length);
 *
 *              //Check GPOS for tags that is not in GSUB
 *              GposNewTags=0;
 *              if (!GposLangSys.IsNull)
 *              {
 *                  for(i=0;i<GposFeatureCount;i++)
 *                  {
 *                      ushort FeatureIndex = GposLangSys.GetFeatureIndex(GposTable,i);
 *                      uint GposTag = GposFeatureList.FeatureTag(GposTable,FeatureIndex);
 *                      if (TagInfo.IsNewTag(Features,GposTag))
 *                      {
 ++GposNewTags;
 *                      }
 *                  }
 *              }
 *
 *              //append new tags to ScriptTags if any exists
 *              if (GposNewTags>0)
 *              {
 *                  //Allocate new array to fit all tags
 *                  TagInfo[] tmp = Features;
 *                  Features = new TagInfo[GsubFeatureCount+GposNewTags];
 *                  Array.Copy(tmp,0,Features,0,tmp.Length);
 *
 *                  for(i=0;i<GposFeatureCount;i++)
 *                  {
 *                      ushort FeatureIndex = GposLangSys.GetFeatureIndex(GposTable,i);
 *                      uint GposTag = GposFeatureList.FeatureTag(GposTable,FeatureIndex);
 *
 *                      if (TagInfo.IsNewTag(Features,GposTag))
 *                      {
 *                          Features[CurrentFeatureIndex].Tag = GposTag;
 *                          Features[CurrentFeatureIndex].TagFlags = TagInfoFlags.Positioning;
 ++CurrentFeatureIndex;
 *                      }
 *                      else
 *                      {
 *                          int Index = TagInfo.GetTagIndex(Features,GposTag);
 *                          Features[Index].TagFlags |= TagInfoFlags.Positioning;
 *                      }
 *                  }
 *
 *                  Debug.Assert(CurrentFeatureIndex==Features.Length);
 *              }
 *
 *
 *          }
 *          catch (FileFormatException)
 *          {
 *              return OpenTypeLayoutResult.BadFontTable;
 *          }
 *
 *          return OpenTypeLayoutResult.Success;
 *      }
 */

        /// <summary>
        /// Substitutes glyphs according to features defined in the font.
        /// </summary>
        /// <param name="Font">In: Font access interface</param>
        /// <param name="workspace">In: Workspace for layout engine</param>
        /// <param name="ScriptTag">In: Script tag</param>
        /// <param name="LangSysTag">In: LangSys tag</param>
        /// <param name="FeatureSet">In: List of features to apply</param>
        /// <param name="featureCount">In: Actual number of features in <paramref name="FeatureSet"/></param>
        /// <param name="featureSetOffset">In: offset of input characters inside FeatureSet</param>
        /// <param name="CharCount">In: Characters count (i.e. <paramref name="Charmap"/>.Length);</param>
        /// <param name="Charmap">In/out: Char to glyph mapping</param>
        /// <param name="Glyphs">In/out: List of GlyphInfo structs</param>
        /// <returns>Substitution result</returns>
        internal static OpenTypeLayoutResult SubstituteGlyphs(
            IOpenTypeFont Font,                     // In: Font access interface
            OpenTypeLayoutWorkspace workspace,      // In: Workspace for layout engine
            uint ScriptTag,                         // In: Script tag
            uint LangSysTag,                        // In: LangSys tag
            Feature[]               FeatureSet,     // In: List of features to apply
            int featureCount,                       // In: Actual number of features in FeatureSet
            int featureSetOffset,
            int CharCount,                          // In: Characters count (i.e. Charmap.Length);
            UshortList Charmap,                     // In/out: Char to glyph mapping
            GlyphInfoList Glyphs                    // In/out: List of GlyphInfo structs
            )
        {
            try
            {
                FontTable GsubTable = Font.GetFontTable(OpenTypeTags.GSUB);
                if (!GsubTable.IsPresent)
                {
                    return(OpenTypeLayoutResult.ScriptNotFound);
                }

                GSUBHeader GsubHeader = new GSUBHeader(0);
                ScriptList ScriptList = GsubHeader.GetScriptList(GsubTable);

                ScriptTable Script = ScriptList.FindScript(GsubTable, ScriptTag);
                if (Script.IsNull)
                {
                    return(OpenTypeLayoutResult.ScriptNotFound);
                }

                LangSysTable LangSys = Script.FindLangSys(GsubTable, LangSysTag);
                if (LangSys.IsNull)
                {
                    return(OpenTypeLayoutResult.LangSysNotFound);
                }

                FeatureList FeatureList = GsubHeader.GetFeatureList(GsubTable);
                LookupList  LookupList  = GsubHeader.GetLookupList(GsubTable);

                LayoutEngine.ApplyFeatures(
                    Font,
                    workspace,
                    OpenTypeTags.GSUB,
                    GsubTable,
                    new LayoutMetrics(), //it is not needed for substitution
                    LangSys,
                    FeatureList,
                    LookupList,
                    FeatureSet,
                    featureCount,
                    featureSetOffset,
                    CharCount,
                    Charmap,
                    Glyphs,
                    null,
                    null
                    );
            }
            catch (FileFormatException)
            {
                return(OpenTypeLayoutResult.BadFontTable);
            }

            return(OpenTypeLayoutResult.Success);
        }
        protected override void OnModelCreating(ModelBuilder builder)
        {
            var id = 0;

            for (id = 0; id < Seeds.Markalar.Length; id++)
            {
                builder.Entity <LookupList>().HasData(
                    new LookupList()
                {
                    Id = id + 1, Tip = Lookup.Marka, Isim = Seeds.Markalar[id]
                }
                    );
            }

            id++;
            builder.Entity <LookupList>().HasData(
                new LookupList()
            {
                Id = id++, Tip = Lookup.Yakit, Isim = "Dizel"
            },
                new LookupList()
            {
                Id = id++, Tip = Lookup.Yakit, Isim = "Benzin"
            },
                new LookupList()
            {
                Id = id++, Tip = Lookup.Yakit, Isim = "LPG"
            },
                new LookupList()
            {
                Id = id++, Tip = Lookup.Yakit, Isim = "Elektrik"
            }
                );

            id++;
            var illist   = Seeds.IlIlce.Select(s => s.Split("-")[0]).Distinct().ToArray();
            var illookup = new List <LookupList>();

            for (var i = 0; i < illist.Length; i++)
            {
                id += i;
                var item =
                    new LookupList()
                {
                    Id = id, Tip = Lookup.Il, Isim = illist[i]
                };
                builder.Entity <LookupList>().HasData(
                    item
                    );
                illookup.Add(item);
            }

            id++;
            for (var i = 0; i < Seeds.IlIlce.Length; i++)
            {
                var    item = Seeds.IlIlce[i];
                var    ililce = item.Split("-");
                string il = ililce[0], ilce = ililce[1];
                id += i;
                builder.Entity <LookupList>().HasData(
                    new LookupList()
                {
                    Id = id++, Tip = Lookup.Ilce, Isim = ilce, ParentId = illookup.Find(s => s.Isim == il).Id
                }
                    );
            }

            id++;
            builder.Entity <LookupList>().HasData(
                new LookupList()
            {
                Id = id++, Tip = Lookup.Bakim, Isim = "Bekliyor"
            },
                new LookupList()
            {
                Id = id++, Tip = Lookup.Bakim, Isim = "Onaylandı"
            },
                new LookupList()
            {
                Id = id++, Tip = Lookup.Bakim, Isim = "Red Edildi"
            },
                new LookupList()
            {
                Id = id++, Tip = Lookup.Bakim, Isim = "Tamamlandı"
            }
                );
            id++;
            var adminrolid = id++;

            builder.Entity <Rol>().HasData(
                new Rol()
            {
                Id = adminrolid, Isim = "Admin"
            }
                );
            builder.Entity <RolMenu>().HasData(
                new RolMenu {
                Id = id++, RolId = adminrolid, MenuNo = 1
            },
                new RolMenu {
                Id = id++, RolId = adminrolid, MenuNo = 2
            },
                new RolMenu {
                Id = id++, RolId = adminrolid, MenuNo = 3
            },
                new RolMenu {
                Id = id++, RolId = adminrolid, MenuNo = 4
            },
                new RolMenu {
                Id = id++, RolId = adminrolid, MenuNo = 5
            },
                new RolMenu {
                Id = id++, RolId = adminrolid, MenuNo = 6
            },
                new RolMenu {
                Id = id++, RolId = adminrolid, MenuNo = 7
            }
                );

            var kullanicirolid = id++;

            builder.Entity <Rol>().HasData(
                new Rol()
            {
                Id = kullanicirolid, Isim = "Kullanıcı"
            }
                );
            builder.Entity <RolMenu>().HasData(
                new RolMenu {
                Id = id++, RolId = kullanicirolid, MenuNo = 1
            },
                new RolMenu {
                Id = id++, RolId = kullanicirolid, MenuNo = 2
            },
                new RolMenu {
                Id = id++, RolId = kullanicirolid, MenuNo = 3
            },
                new RolMenu {
                Id = id++, RolId = kullanicirolid, MenuNo = 4
            }
                );

            var yetkiliservisrolid = id++;

            builder.Entity <Rol>().HasData(
                new Rol()
            {
                Id = yetkiliservisrolid, Isim = "Yetkili Servis"
            }
                );
            builder.Entity <RolMenu>().HasData(
                new RolMenu {
                Id = id++, RolId = yetkiliservisrolid, MenuNo = 1
            },
                new RolMenu {
                Id = id++, RolId = yetkiliservisrolid, MenuNo = 5
            }
                );

            var musterirolid = id++;

            builder.Entity <Rol>().HasData(
                new Rol()
            {
                Id = musterirolid, Isim = "Müşteri"
            }
                );
            builder.Entity <RolMenu>().HasData(
                new RolMenu {
                Id = id++, RolId = musterirolid, MenuNo = 4
            }
                );
        }
Ejemplo n.º 18
0
        private static void ComputeTableCache(
            IOpenTypeFont font,
            OpenTypeTags tableTag,
            int maxCacheSize,
            ref int cacheSize,
            ref GlyphLookupRecord[] records,
            ref int recordCount,
            ref int glyphCount,
            ref int lastLookupAdded
            )
        {
            FontTable table = font.GetFontTable(tableTag);

            if (!table.IsPresent)
            {
                return;
            }

            FeatureList featureList;
            LookupList  lookupList;

            Debug.Assert(tableTag == OpenTypeTags.GSUB || tableTag == OpenTypeTags.GPOS);

            switch (tableTag)
            {
            case OpenTypeTags.GSUB:
            {
                GSUBHeader header = new GSUBHeader();
                featureList = header.GetFeatureList(table);
                lookupList  = header.GetLookupList(table);
                break;
            }

            case OpenTypeTags.GPOS:
            {
                GPOSHeader header = new GPOSHeader();
                featureList = header.GetFeatureList(table);
                lookupList  = header.GetLookupList(table);
                break;
            }

            default:
            {
                Debug.Assert(false);
                featureList = new FeatureList(0);
                lookupList  = new LookupList(0);
                break;
            }
            }

            // Estimate number of records that can fit into cache using ratio of approximately
            // 4 bytes of cache per actual record. Most of fonts will fit into this value, except
            // some tiny caches and big EA font that can have ratio of around 5 (theoretical maximum is 8).
            //
            // If actual ratio for particluar font will be larger than 4, we will remove records
            // from the end to fit into cache.
            //
            // If ratio is less than 4 we actually can fit more lookups, but for the speed and because most fonts
            // will fit into cache completely anyway we do not do anything about this here.
            int maxRecordCount = maxCacheSize / 4;

            // For now, we will just allocate array of maximum size.
            // Given heuristics above, it wont be greater than max cache size.
            //
            records = new GlyphLookupRecord[maxRecordCount];

            //
            // Now iterate through lookups and subtables, filling in lookup-glyph pairs list
            //
            int lookupCount = lookupList.LookupCount(table);
            int recordCountAfterLastLookup = 0;

            //
            // Not all lookups can be invoked from feature directly,
            // they are actions from contextual lookups.
            // We are not interested in those, because they will
            // never work from high level, so do not bother adding them to the cache.
            //
            // Filling array of lookup usage bits, to skip those not mapped to any lookup
            //
            BitArray lookupUsage = new BitArray(lookupCount);

            for (ushort feature = 0; feature < featureList.FeatureCount(table); feature++)
            {
                FeatureTable featureTable = featureList.FeatureTable(table, feature);

                for (ushort lookup = 0; lookup < featureTable.LookupCount(table); lookup++)
                {
                    ushort lookupIndex = featureTable.LookupIndex(table, lookup);

                    if (lookupIndex >= lookupCount)
                    {
                        // This must be an invalid font. Just igonoring this lookup here.
                        continue;
                    }

                    lookupUsage[lookupIndex] = true;
                }
            }
            // Done with lookup usage bits

            for (ushort lookupIndex = 0; lookupIndex < lookupCount; lookupIndex++)
            {
                if (!lookupUsage[lookupIndex])
                {
                    continue;
                }

                int  firstLookupRecord = recordCount;
                int  maxLookupGlyph    = -1;
                bool cacheIsFull       = false;

                LookupTable lookup        = lookupList.Lookup(table, lookupIndex);
                ushort      lookupType    = lookup.LookupType();
                ushort      subtableCount = lookup.SubTableCount();

                for (ushort subtableIndex = 0; subtableIndex < subtableCount; subtableIndex++)
                {
                    int subtableOffset = lookup.SubtableOffset(table, subtableIndex);

                    CoverageTable coverage = GetSubtablePrincipalCoverage(table, tableTag, lookupType, subtableOffset);

                    if (coverage.IsInvalid)
                    {
                        continue;
                    }

                    cacheIsFull = !AppendCoverageGlyphRecords(table, lookupIndex, coverage, records, ref recordCount, ref maxLookupGlyph);

                    if (cacheIsFull)
                    {
                        break;
                    }
                }

                if (cacheIsFull)
                {
                    break;
                }

                lastLookupAdded            = lookupIndex;
                recordCountAfterLastLookup = recordCount;
            }

            // We may hit storage overflow in the middle of lookup. Throw this partial lookup away
            recordCount = recordCountAfterLastLookup;

            if (lastLookupAdded == -1)
            {
                // We did not succeed adding even single lookup.
                return;
            }

            // We now have glyph records for (may be not all) lookups in the table.
            // Cache structures should be sorted by glyph, then by lookup index.
            Array.Sort(records, 0, recordCount);

            cacheSize  = -1;
            glyphCount = -1;

            // It may happen, that records do not fit into cache, even using our heuristics.
            // We will remove lookups one by one from the end until it fits.
            while (recordCount > 0)
            {
                CalculateCacheSize(records, recordCount, out cacheSize, out glyphCount);

                if (cacheSize <= maxCacheSize)
                {
                    // Fine, we now fit into max cache size
                    break;
                }
                else
                {
                    // Find last lookup index
                    int lastLookup = -1;
                    for (int i = 0; i < recordCount; i++)
                    {
                        int lookup = records[i].Lookup;

                        if (lastLookup < lookup)
                        {
                            lastLookup = lookup;
                        }
                    }

                    Debug.Assert(lastLookup >= 0); // There are lookups, so there was an index

                    // Remove it
                    int currentRecord = 0;
                    for (int i = 0; i < recordCount; i++)
                    {
                        if (records[i].Lookup == lastLookup)
                        {
                            continue;
                        }

                        if (currentRecord == i)
                        {
                            continue;
                        }

                        records[currentRecord] = records[i];
                        currentRecord++;
                    }

                    recordCount = currentRecord;

                    // Do not forget update lastLookupAdded variable
                    lastLookupAdded = lastLookup - 1;
                }
            }

            if (recordCount == 0)
            {
                // We can't fit even single lookup into the cache
                return;
            }

            Debug.Assert(cacheSize > 0);  // We've calcucalted them at least ones, and
            Debug.Assert(glyphCount > 0); // if there is no records, we already should've exited
        }
Ejemplo n.º 19
0
 public virtual IActionResult LookuplistsIdPut([FromRoute] int id, [FromBody] LookupList item)
 {
     return(this._service.LookuplistsIdPutAsync(id, item));
 }
Ejemplo n.º 20
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id">id of LookupList to fetch</param>
        /// <param name="item"></param>
        /// <response code="200">OK</response>
        /// <response code="404">LookupList not found</response>
        public virtual IActionResult LookuplistsIdPutAsync(int id, LookupList item)
        {
            var result = "";

            return(new ObjectResult(result));
        }
Ejemplo n.º 21
0
 /// <summary>
 /// Setup the test.
 /// </summary>
 public LookupListModelTests()
 {
     instance = new LookupList();
 }